DDL:
CREATE DATABASE <Datbase_name>;
use <database_name<;
CREATE TABLE Student(rno int, name varchar(40), mark1 integer, mark2 integer, PRIMARY KEY (rno));
ALTER TABLE student modify rno INT NOT NULL AUTO_INCREMENT;
ALTER TABLE student add course varchar(40);
DROP TABLE student;
Drops the table and recreates the structure:
Truncate student;
To know table metadata:
desc student;
DML:
Insert
select
Delete
update
insert into student(rno,name,mark1,mark2) values(1, 'a',34,45);
insert into student(name,mark1,mark2) values('b',34,45);
insert into student values(null, 'b',34,45);
insert into student values(null, 'aa',37,46);
Select * from student;
Select name,mark1 from student where rno=2;
Select name,mark1 from student where name like 'a%';
update student set mark2 = 70 where rno=2;
Select name,mark2 from student;
delete from student where rno=3;
Select avg(mark1) from student;
Select course, avg(mark1) from student group by course;
No comments:
Post a Comment