mysql基本语句

来源:互联网 发布:帝霸传奇手游源码 编辑:程序博客网 时间:2024/06/05 17:15
0-------Sql数据库基本操作语句----------1.显示数据库show datebase;2.显示数据库中的表show tables;3.显示表的结构describe 表名;4.显示表中的记录select* from 表名;5.新建数据库create datebase数据库名;6.新建表create table 表名(数据字段);字段约束  1.null/ not null  2.defaultcreate table t2(id int not null default 0, name varchar(20));  3.zerofill用0来填充字段前面的位,例如int的数有11位,如果给它赋值7,则结果是0000 0000 007。  4.auto_increment自动加1索引  1.primary key2.unique key7.增加表全部记录insert into 表名 values(所有字段);8.增加表部分记录insert into 表名(字段1,字段2) values(数据1,数据2);9.修改表记录update 表名 set 要修改字段=新数据 where 查找字段=数据;10.删除记录delete from 表名 where 查找字段=数据;11.删除数据库drop datebase 数据库名;12.删除表drop table 表名;13.数据库登陆use 数据库名;14.数据库退出exit;15.创建用户create user happy identified by ‘123456’;16.删除用户drop user happy;17.显示用户权限show grants for happy;18.给用户权限(all这个词可以替换为select,insert, update, delete)grant all on orders.* to happy;19.回收权限revoke all on orders.* from happy;20.修改用户名rename user happy to happy1;21.修改密码set PASSWORD=password(’654321’);set password for happy=password(‘123456’);

0 0
原创粉丝点击