The document discusses SQL commands to create, modify, insert data into, display, update, and order data from a student database table. It includes commands to create a database and student table, add and modify columns, insert records, display all records, update a record, and order the records by ID descending and name ascending.
The document discusses SQL commands to create, modify, insert data into, display, update, and order data from a student database table. It includes commands to create a database and student table, add and modify columns, insert records, display all records, update a record, and order the records by ID descending and name ascending.
The document discusses SQL commands to create, modify, insert data into, display, update, and order data from a student database table. It includes commands to create a database and student table, add and modify columns, insert records, display all records, update a record, and order the records by ID descending and name ascending.
use studentdb; create table student123(sid int,sname varchar(30),marks int); desc student123;
Implement the following SQL commands on the student table:
ALTER table to add new attributes/ modify data type /
drop attribute 1. alter table student123 add primary key(sid); // the above line is for adding constraint i.e., primary key 2. alter table student123 add(total int); // the above line is for adding new attribute 3. alter table student123 modify total float(3,2); //the above line is to modify data type of a column
4. alter table student123 drop total;
//the above line is to drop column INSERT data into the table. insert into student123 values(1,'ABC',99); insert into student123 values(2,'PQR',89); insert into student123 values(3,'PQR',86); Display data by using SELECT command select * from student123;
UPDATE table to modify data
update student123 set sname='XYZ' where sid=3;
ORDER By to display data in ascending/ descending order.