Shubh Kotwal

Phots

Blog

sql

Posted by shubhamk[email protected] on April 9, 2017 at 12:35 AM

Create Table example:

create table student(sno int primary key, name varchar(30),status char,birthdate date,salary money,pno int references project(pno)on delete cascade on update cascade);

 


Insert Into Table:

insert into studenht values(1,'shubham','I');

 


Select Examples:

select ename from employee,department where dname='finance' and city='Pune' and department.dno=employee.dno;

 


Update Example:

update student set class='SYBCS' where rno=3;

 


Delete Examples:

delete from project where pname='soft computing';

//for delete whole data :

delete from student;

 


Add New Column:

alter table tablename add colum_name datatype;

 


Drop Column:

alter table project drop remark;

 


Change Datatype:

alter table table_name alter column_name type new_datatype;

 


Rename Column:

alter table table_name rename oldcolumn_name to newcolumn_name;

 


Rename Table:

alter table table_name rename to newtable_name;

 


Add Constraint:

alter table table_name add contraint constraint_name unique(column_name);

 


Drop a Table:

drop table table_name;

 

Categories: None

Post a Comment

Oops!

Oops, you forgot something.

Oops!

The words you entered did not match the given text. Please try again.

Already a member? Sign In

0 Comments