PW Akshay

Generation

generate functionFri, 02 Dec 2022

Create a student table and insert data. Implement the following SQL commands on the student table: 1. ALTER table to add new attributes / modify data type / drop attribute 2. UPDATE table to modify data 3. ORDER By to display data in ascending / descending order 4. DELETE to remove tuple(s) 5. GROUP BY and find the min, max, sum, count and average

import sqlite3 conn = sqlite3.connect('student.db') c = conn.cursor() #create cursor c.execute('''DROP TABLE IF EXISTS student''') c.execute('''CREATE TABLE student ( id INTEGER PRIMARY KEY, name TEXT, age INTEGER, marks INTEGER)''') c.execute('''INSERT INTO student VALUES (1, "Gill", 15, 80)''') c.execute('''INSERT INTO student VALUES (2, "Ben", 14, 75)''') c.execute('''INSERT INTO student VALUES (3, "Joe", 14, 65)''') c.execute('''INSERT INTO student VALUES (4, "Will", 15, 45)''') c.execute('''INSERT INTO student VALUES (5, "Calvin", 16, 80)''') c.execute('''INSERT INTO student VALUES (6, "James", 13, 40)''') c.execute('''

Questions about programming?Chat with your personal AI assistant