PW Akshay


generate functionFri, 02 Dec 2022

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

''' def alter_table(cursor,table_name,column_name,data_type): query = "ALTER TABLE "+table_name+" ADD "+column_name+" "+data_type+";" cursor.execute(query) connection.commit() print("Table altered successfully") alter_table(cursor,"student","enrollment", "int(10)") def update_table(cursor,table_name,column_name,value,condition): query = "UPDATE "+table_name+" SET "+column_name+" = '"+value+"' WHERE "+condition+";" cursor.execute(query) connection.commit() print("Table updated successfully") update_table(cursor,"student","enrollment","123456789","name = 'charlie'") def delete_table(cursor,table_name,condition): query = "DELETE FROM "+table_name+" WHERE "+condition+";" cursor.execute(query) connection.commit()

Questions about programming?Chat with your personal AI assistant