mysql的常用命令
--库级命令:
---建库:
create database 【if not exists】school;
school为库名
---删除库:
drop database 【if exists】test;
test为库名
---查看所有的库
show databases;
---建库时指定字符编码
create database school character set 'utf8';
---修改库的字符编码
alter database school character set 'utf8';
if not exists相当于抛出异常
if exists
---使用库语句。切换到具体的数据库school
use school;
---给外部访问权
grant all on *.* to 'root'@'%' identified by 'ok'
flush privileges;
--表级语句
---建表语句
create table [if not exists] [库名.]表名(
列名 列类型 (列长度) 列属性
---查看已经建好的表结构;
desc 表名
---查看已经建好的表的建表语句(完全版,部分可省略)
show create table 表名;
---删除表:
drop table 表名
---修改表的表名、列名、列类型、属性等
alter 表名....;
---自增
auto_increment