约束中 加 comment ‘用户名称’ 表示注解
grant命令创建用户、授权、修改密码等功能于一体的命令
grant 后面跟权限 all表示全部
grant all【select,undate,drop,creat】on *.*to 用户名称 identified by 密码
select * from 数据库名称.表名称 #查表所有
delete from 表名称 where 条件;
SQL中只有数字可以不用引号,其他必须要有引号,否则会报错
CURD增删改查
c(create);
R(read);
U(update);
D(delete);
insert 增加
insert into 表名称(字段1,字段2,字段3…)values(值1,值2,值3…);
insert into 表名称 values(值1,值2,值3);
update 修改
update 表名称 set 字段1=新值,字段2=新值 where 条件
案例:
update t_xiyou set name=“lilei” where id=2;
注意:
update t_xiyou set age=age+1 ; #没有条件,所有都会加1
delete删除
delete from 表明 where 条件;
案例:
delete from t_xiyou where id=1;
truncat 命令 清除数据 风险十分大,不经过数据字典,再也回不来。
truncat 表名称;
read查询
select 字段1,字段2…字段n from 表名称 where 条件;
案例:
select id name from t_xiyou;
select * from t_xiyou where id=1;
alter指令能不用则不用!!!
alter主要用来修改表的结构!!!
案例:
增加表的字段:
alter table t_xiyou add gender char(2) default ‘女’;
删除表的字段:
alter table t_xiyou drop gender;
1102

被折叠的 条评论
为什么被折叠?



