SQL的学习

create database hpf;
use hpf;
create table hdfdf (
id int(10) NOT null auto_increment,
uid varchar(10) not null default 0,
remark text null,
primary key (id)
)
show tables;
select * from hdfdf;
select id as idenfiy from hdfdf;
select * from test where id!=1;
select * from test where id<>1;
select * from test where id in (1,2);
select * from test where id not in (1,2);
select * from test where id between 1 and 3;
select * from test where id not between 1 and 3;
select * from test where id=1 and remark="学生";
select * from test group by remark;
select * from test order by regdate (asc\desc);
select * from test limit 0,3;
select * from test ;
select count(*) as num from test;
select max(id) as num from test;
select min(id) from test;
select avg(id) from test;
select sum(id) from test;
select * from test where uid like '%王%';
alter table hdfdf drop remark;
alter table hdfdf add remark text null after id;
alter table hdfdf add name varchar(20) null;
insert into test (uid,regdate,remark) values (5,now(),'老师');
update test set uid='万网' where id=5;
delete from test where id=6






create table message(
id tinyint(1) not null auto_increment,
user varchar(25) not null,
title varchar(50) not null,
content tinytext not null,
lastdate date not null,
primary key (id)
)engine=InnoDB default charset=gbk auto_increment=1;






select * from message;

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。