हिंदी

Differentiate between the following statement: ALTER and UPDATE

Advertisements
Advertisements

प्रश्न

Differentiate between the following statement:

ALTER and UPDATE

अंतर स्पष्ट करें
Advertisements

उत्तर

Alter

  • ALTER command is Data Definition Language (DDL).
  • ALTER command will perform the action on the structure level and not on the data level.
  • ALTER Command is used to add, delete, and modify the attributes of the relations (tables) in the database.

Update

  • UPDATE Command is a Data Manipulation Language (DML).
  • UPDATE command will perform on the data level.
  • UPDATE Command is used to update existing records in a database.
shaalaa.com
SQL for Data Definition
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 9: Structured Query Language (SQL) - Exercise [पृष्ठ १७७]

APPEARS IN

एनसीईआरटी Computer Science [English] Class 12
अध्याय 9 Structured Query Language (SQL)
Exercise | Q 1. e) i) | पृष्ठ १७७

संबंधित प्रश्न

Each table comprises of ______  and ______.


Case Based

Consider the table STUDENT with the following detail.

STU_ID NAME STREAM MARKS CLASS
1. Aditya Science 87.5 12A
2. Vikram Commerce 88.7 12B
3. Astha Humanities 76.8 12C
4. Varsha Science 79.5 12A
5. Kanishka Science 77.9 12A
6. Anand Commerce 86.7 12B

Now answer the question given below:

Command to select all Science students from the table STUDENT


Case Based

Consider the table STUDENT with the following detail.

STU_ID NAME STREAM MARKS CLASS
1. Aditya Science 87.5 12A
2. Vikram Commerce 88.7 12B
3. Astha Humanities 76.8 12C
4. Varsha Science 79.5 12A
5. Kanishka Science 77.9 12A
6. Anand Commerce 86.7 12B

Now answer the question given below:

Delete records that belongs to 'Humanities' stream.


Which of the following command is used to remove a relation from an SQL database?


Which of the following is not an RDBMS?


Which of the following are included in defining a schema?


To know the names of existing databases, we use the statement:


What is not true with respect to the create table statement?


What statement will you give to view the structure of a table?


How will you add a foreign key to a relation?


Which statement is used to remove a table from the database?


Raju's date of birth is 21/06/2006. How will his date be added to database?


Using the CARSHOWROOM database given in the chapter, write the SQL queries for the following:

  1. Add a new column Discount in the INVENTORY table.
  2. Set appropriate discount values for all cars keeping in mind the following:
    (i) No discount is available on the LXI model.
    (ii) VXI model gives a 10 percent discount.
    (iii) A 12 percent discount is given on cars other than the LXI model and VXI model.
  3. Display the name of the costliest car with the fuel type “Petrol”.
  4. Calculate the average discount and total discount available on Baleno cars.
  5. List the total number of cars having no discount.

Which of the following commands will delete the table from the MYSQL database?


______ is a non-key attribute, whose values are derived from the primary key of some other table.


Write the command to view all tables in a database.


The code given below reads the following record from the table named student and displays only those records that have marks greater than 75:

  • RollNo - integer
  • Name - string
  • Clas - integer
  • Marks - integer

Note the following to establish connectivity between Python and MYSQL:

  • Username is root.
  • The password is the tiger.
  • The table exists in an MYSQL database named school.

Write the following missing statements to complete the code:

Statement 1 - to form the cursor object
Statement 2 - to execute the query that extracts records of those students whose marks are greater than 75.
Statement 3 - to read the complete result of the query (records whose marks are greater than 75) into the object named data, from the table student in the database.

import mysql.connector as mysql
def sql_data():
       con1=mysql.connect(host="localhost",user="root",password="tiger", database="school")
       mycursor=_______________ #Statement 1
       print("Students with marks greater than 75 are :")
                  _________________________ #Statement 2
                 data=__________________ #Statement 3
                for i in data:
                   print(i)
                print()

Write the command to view all databases.


Name any two DDL commands.


Consider the table Personal given below:

Table: Personal
P_ID Name Desig Salary Allowance
P01 Rohit Manager 89000 4800
P02 Kashish Clerk NULL 1600
P03 Mahesh Superviser 48000 NULL
P04 Salil Clerk 31000 1900
P05 Ravina Superviser NULL 2100

Based on the given table, write SQL queries for the following:

  1. Increase the salary by 5% of personals whose allowance is known.
  2. Display Name and Total Salary (sum of Salary and Allowance) of all personals. The column heading ‘Total Salary’ should also be displayed.
  3. Delete the record of Supervisors who have salary greater than 25000.

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×