mysql基本操作

01、显示所有的数据库文件: show databases;

02、创建数据库: create database 数据库名;

03、选择数据库: use 数据库名;

04、显示当前数据库中所有表: show tables;

05创建表:

create table 表名(字段名1 字段类型 约束,

                            字段名2 字段类型 约束,

                            字段名3 字段类型 约束);

06查看表结构:

desc 表名;

 

 

07复制 表结构:create table 新表名 like 旧表名;

08删除表

drop table 表名;

09删除数据库

drop database 数据库名;

10

修改数据表alter table 表名:

增加字段 add:

alter table student add stu_sex char(5);

修改字段类型  modify: 

alter table studeng modify  stu_sex  enum('f','m');   

修改字段名称   change:

alter table student chang stu_sex  Ssex  enum('f','m');

删除字段    drop:

alter table student drop Ssex;

修改表名    rename 把student表重命名为xsb:

alter table student rename xsb;

 

posted @ 2019-04-12 08:36  勇敢的人不败的心  阅读(185)  评论(0)    收藏  举报