首页 > 代码库 > sql常用语句

sql常用语句

select * from personselect distinct name from personselect * from person where name=huangcongcongselect * from person where year>1991select * from person order by idselect * from person limit 5select * from person name like "%cong%"select * from person name like "[!hc]%"select * from person where name in(huangcongcong,huangbingbing)select * from person where name between huangbingbing and huangcongcongselect name as xingming from personselect * from person where name is nullselect * into person_back from personinsert into person (name,year) values(huangbingbing,1992)update person set year=1990 where name=huangbingbingdelete from person where name=huangcongcongdelete * from persondelete from personcreate database my_dbcreate table person(    id int not null primary key check(id>0) auto_increment,    name varchar(50) not null,    address varchar(50) default shanghai,    city varchar(50),    foreign key (id) references order(id))alter table personadd unique (id)alter table persondrop index idalter table personadd primary key(id)alter table persondrop primary keyalter table personadd foreign key (id) references order(id)alter table persondrop foreign keyalter table personadd check(id>0)alter table persondrop constraint checkalter table personadd constraint chk_person check(id>0)alter table persondrop constraint chk_personalter table personalter city set default shenzhenalter table personalter city drop defaultcreate index personIndexon person namealter table persondrop index personIndexalter table personauto_increment=100create view personViewselect * from person

 

sql常用语句