abstrait:-- 創(chuàng)建表 drop table if exists user; create table user( `id` mediumint(5) not null auto_increment comment '主鍵', `name` varcha
-- 創(chuàng)建表 drop table if exists user; create table user( `id` mediumint(5) not null auto_increment comment '主鍵', `name` varchar(100) not null default '' comment '用戶名', `sex` tinyint(2) comment '性別:0男;1女', `age` tinyint(3) unsigned comment '年齡', `email` varchar(200) not null default '' comment '郵箱', `password` char(40) not null default '' comment '密碼', `status` tinyint(1) not null default 0 comment '用戶狀態(tài):0未啟用;1啟用', `create_time` int(10) not null default 0 comment '注冊時(shí)間', primary key(`id`) using btree, unique index `name`(`name`) using btree ); -- 插入 insert into `user` values('','楊康',0,26,'yk@php.com',sha1(123456),1,1543223803),('','歐陽克',0,25,'oyk@php.com',sha1(123456),1,1543223867); -- 更新 update `user` set `age` = 26,`status` = 0 where id = 4; -- 查詢 select `name`,`sex`,`age`,`email`,`status` from `user` where `status` = 1 order by `age` desc limit 2; -- 執(zhí)行簡單運(yùn)算 select 15*2 `res`; -- 拼接字符串(直接拼接) select concat(`id`,`name`) `user_str` from `user` where `status` = 1; -- 拼接字符串(兩個(gè)拼接的字符串之間有自定義連接符號) select concat_ws(':',`id`,`name`) `user_str` from `user` where `status` = 1; select count(`id`) `num` from `user` where `status` = 1; -- 刪除 delete from `user` where `id` = 5; -- id重新排列 alter table `user` drop `id`; alter table `user` add `id` int(5) primary key not null auto_increment first;
Professeur correcteur:天蓬老師Temps de correction:2018-11-26 17:49:15
Résumé du professeur:很好,常用命令,遠(yuǎn)遠(yuǎn)不止這幾個(gè), 把重點(diǎn)放在條件設(shè)置上 好好干