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_records.db') c = conn.cursor() # Create table c.execute('''CREATE TABLE IF NOT EXISTS student (id INTEGER PRIMARY KEY, name text, gender text, age INTEGER, grade REAL, dept text)''') # Insert a row of data c.execute("INSERT INTO student VALUES (1, 'Mary', 'female', 20, 'A', 'CSE')") c.execute("INSERT INTO student VALUES (2, 'John', 'male', 21, 'B', 'CSE')") c.execute("INSERT INTO student VALUES (3, 'Jane', 'female', 20, 'A+', 'CSE')") c.execute("INSERT INTO student VALUES (4, 'Mike', 'male', 20, 'A+', 'CSE')") c.execute("INSERT INTO student VALUES (5, 'Tom', 'male', 21, 'B+', 'CSE')") c.execute("INS

Questions about programming?Chat with your personal AI assistant