MySQL查詢表與表字段的資訊

2022-01-12 20:39:28 字數 1292 閱讀 9135

環境:

mysql資料庫

庫名:db_name

表名: table_name1 table_name2

查詢乙個裡面所有表的資訊:

use information_scheam;

select * from tables where table_schema = "

db_name

";

查詢單個表的資訊:

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;

一些基礎:

# 建立表

create table book(

id int(11) primary key,

title varchar(50) comment '書名'

, author varchar(32) comment '作者'

, price int(8) comment '**'

);# 修改表備註資訊

alter table student comment '書籍表';

# 修改表字段長度

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;

# 檢視表備註資訊和表字段備註資訊請看上文。

MySQL查詢表與表字段的資訊

環境 mysql資料庫 庫名 db name 表名 table name1 table name2 查詢乙個裡面所有表的資訊 use information scheam select from tables where table schema db name 查詢單個表的資訊 use infor...

查詢oracle表字段資訊

查詢oracle表字段資訊 表字段的資訊咱們可以稱之為元資料,今天有人問怎麼把表字段的資訊匯出來,說實話我還不會用plsql develper把錶的結構匯出來,像下圖所示 在寫資料庫設計說明書的時候,想要把這個 拷貝出來,這樣就事半功倍,不用乙個個複製貼上了,而且減少出錯的概率,但遺憾的是,這個介面...

根據系統表查詢使用者表字段資訊

在sql server中查詢字段資訊的語句 select a.name as tablename,b.name as columnname,case when h.id is not null then pk else no end as primarykey,type name b.xuserty...