English

Categorize the following commands as DDL or DML: INSERT, UPDATE, ALTER, DROP - Computer Science (Python)

Advertisements
Advertisements

Question

Categorize the following commands as DDL or DML:

INSERT, UPDATE, ALTER, DROP

One Line Answer

Solution

DDL - ALTER, DROP

DML - INSERT, UPDATE

shaalaa.com
Performing Insert, Update, Delete Queries Using Cursor
  Is there an error in this question or solution?
2022-2023 (March) Sample

RELATED QUESTIONS

Differentiate between the following statement:

DELETE and DROP


A shop called Wonderful Garments which sells school uniforms maintains a database SCHOOLUNIFORM as shown below. It consisted of two relations - UNIFORM and COST. They made UniformCode the primary key for UNIFORM relations. Further, they used UniformCode and Size to be composite keys for COSTrelation. By analyzing the database schema and database state, specify SQL query to rectify the following anomaly.

M/S Wonderful Garments also keeps handkerchiefs of red colour, medium size of Rs. 100 each.


The code given below inserts the following record in the table Student:

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

Note the following to establish connectivity between Python and MYSQL:

  • Username is root
  • Password is tiger
  • The table exists in an MYSQL database named school.
  • The details (RollNo, Name, Clas and Marks) are to be accepted by the user.

Write the following missing statements to complete the code:

Statement 1 - to form the cursor object.

Statement 2 - to execute the command that inserts the record in the table Student.

Statement 3 - to add the record permanently to the database.

import mysql.connector as mysql
def sql_data():
        con1=mysql.connect(host="localhost",user="root",password="tiger", database="school")
 mycursor=_________________ #Statement 1 
 rno=int(input("Enter Roll Number :: "))
 name=input("Enter name :: ")
 clas=int(input("Enter class :: "))
 marks=int(input("Enter Marks :: "))
 querry="insert into student 
values({},'{}',{},{})".format(rno,name,clas,marks)
--------------------#Statement 2
--------------------# Statement 3
 print("Data Added successfully")

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×