MySQL查詢表與表字段的信息

環(huán)境:

Mysql數(shù)據(jù)庫

庫名: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;

創(chuàng)建表

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;

查看表備注信息和表字段備注信息

show full columns from book;
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

  • 什么是數(shù)據(jù)庫? 數(shù)據(jù)庫是存儲數(shù)據(jù)的集合的單獨的應用程序。每個數(shù)據(jù)庫具有一個或多個不同的API,用于創(chuàng)建,訪問,管理...
    chen_000閱讀 4,132評論 0 19
  • 作者:燁竹 數(shù)據(jù)庫的基本操作 登陸MySQL數(shù)據(jù)庫服務:mysql -h服務器地址 -P端口號 -u用戶名 ...
    DragonRat閱讀 1,441評論 0 7
  • 今天看到一位朋友寫的mysql筆記總結,覺得寫的很詳細很用心,這里轉載一下,供大家參考下,也希望大家能關注他原文地...
    信仰與初衷閱讀 4,826評論 0 30
  • 一、數(shù)據(jù)庫概述 什么是數(shù)據(jù)庫數(shù)據(jù)庫就是存儲數(shù)據(jù)的倉庫,其本質是一個文件系統(tǒng),數(shù)據(jù)按照特定的格式將數(shù)據(jù)存儲起來,用戶...
    圣賢與無賴閱讀 4,062評論 0 4
  • MySQL數(shù)據(jù)庫 課程目標:1.如何使用MySQL數(shù)據(jù)庫,主要是講解基本的語法2.如何設計數(shù)據(jù)庫? 第一章 數(shù)據(jù)庫...
    我愛開發(fā)閱讀 1,402評論 1 4

友情鏈接更多精彩內容