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 connection = sqlite3.connect(':memory:') cursor = connection.cursor() cursor.execute('CREATE TABLE student(roll_no INTEGER PRIMARY KEY, name TEXT, age INTEGER);') cursor.execute('INSERT INTO student(name, age) VALUES ("student0", 9);') cursor.execute('INSERT INTO student(name, age) VALUES ("student1", 10);') cursor.execute('INSERT INTO student(name, age) VALUES ("student2", 8);') cursor.execute('INSERT INTO student(name, age) VALUES ("student3", 9);') cursor.execute('INSERT INTO student(name, age) VALUES ("student4", 8);') cursor.execute('INSERT INTO student(name, age) VALUES ("student5", 10);') cursor.execute('INSERT INTO student(name, age) VALUES ("student6", 8);') cursor.execute('INSERT INTO student(name, age) VALUES ("student7", 9);

Questions about programming?Chat with your personal AI assistant