create table[if not exists] table1(
col1 int,
col2 varchar(30),
col3 double(3,2)
);
show databases;
use table1;
show table from 数据库名称;
show columns from table1;
insert [into] table1 values(1,‘1’,0.0);
insert into table1(col1) values(1);
alter table table1 modify col1 int auto_increment primary key;
alter table table1 modify col2 varchar(30) unique key ;
alter table table1 modify col3 varchar(30) default ‘0’;
alter table table1 modify col1 int NULL;
create table tb1(
i int references table1(clo1) on cascade
);
cascade, set null ,restrict,no action
alter table table1add [column] col4 int ;
alter table table1 add column col5 varchar(30) after col3;
alter table table1 add column col6 varchar(30) first;
alter table table1 drop column col4;
alter table table1 drop primary key;
alter table table1 drop INDEX column_name;
insert table1 values(…),(…),(…);
insert table set col1=1,col2=‘1’;
update table1 set col1=col1+5;
updata table1 set col1=col1+1 where col1=1;;
delete from table1 where col1=1;
select col1,col2 from table1 having where count(col1)>0;
max,min,avg,sum;
select col1 as c1 from table1;
select col1,col2 from users group by col11 ;
select * from table1 order by col1 desc,col2 desc ;
select * from table1 limit 2;
select * from table limit 0,2;
insert table1(…)select col1from table2 where col1>0;