数据库基本命令

2019-07-09  本文已影响0人  爱抽烟的臭屁虫

----创建表 显示地将student表放在mydatabase里

create table if not exists mydatabase.student()

    name varchar(10),

    gender varchar(10),

    number varchar(10),

    age int

    )charset utf8;

----进入数据库

use mydatabase;

----创建表

create table class(

name varchar(10),

room varchar(10),

)charset utf8;

---查看所有表:show tables;

--查看以s结尾的表:

show tables like '%s';

-----查看表的创建语句:

show create table student;

show create table student\g

show create table student\G---将查到的结构旋转90度变成纵向

-----查看表结构:

desc 表名;

describe class;

show columns from class;

----重命名表:student表 -> my_student

rename table student to my_student;

---修改表选项:字符集

alter table my_student charset = GB2312;

---给学生表增加ID,放到第一个位置

alter table my_student

add column id int

first;

上一篇 下一篇

猜你喜欢

热点阅读