環(huán)境:
Mysql數(shù)據(jù)庫(kù)
庫(kù)名:db_name
表名: table_name1 table_name2
查詢一個(gè)里面所有表的信息:
use information_scheam;
select * from tables where table_schema = "db_name";
查詢單個(gè)表的信息:
use information_scheam;
select * from tables where table_schema = "db_name" and table_name = "table_name1";
查詢一張表的所有字段信息:
use db_name;
show full columns from table_name1;
show full columns from table_name2;
創(chuàng)建表
create table book(
id int(11) primary key,
title varchar(50) comment '書(shū)名',
author varchar(32) comment '作者',
price int(8) comment '價(jià)格'
);
修改表備注信息
alter table student comment '書(shū)籍表';
修改表字段長(zhǎng)度
alter table book modify column author varchar(50);
修改表字段備注信息
alter table book modify column author varchar(50) comment '作者姓名';
給表增加新字段
alter table book add publisher varchar(100) comment '出版社';
在指定列后面增加新字段
alter table book add publisher varchar(200) comment '出版社' after author;
刪除表字段
alter table book drop column price;
查看表備注信息和表字段備注信息
show full columns from book;