1 -- 建表语句 2 create table t_user( 3 id int PRIMARY KEY, 4 username varchar(20) not null, 5 userpwd varchar(20) not null 6 ) 7 8 -- 插入数据 9 insert into t_user values(1, 'h_bolin', '123'); 10 insert into t_user values(2, 'h_bolin', '123'); 11 insert into t_user values(3, 'h_bolin', '123'); 12 13 -- 查询数据 14 select * from t_user; 15 select * from t_user where id=1; 16 select count(1) from t_user; 17 18 19 -- 更新语句 20 update t_user set userpwd='456' where id=1; 21 22 -- 删除语句 23 delete from t_user where id=3;
当id自增时:
-- 建表语句 create table t_user( id int PRIMARY KEY not null auto_increment, username varchar(20) not null, userpwd varchar(20) not null )
查询语句如下:
insert 表名(字段2,字段3) values(字段2值,字段3值)
insert into t_user(username,userpwd) values('h_bolin', '123');