mySql資料庫的一些操作

2021-06-21 12:46:57 字數 1169 閱讀 4443

mysql下讀取表中字段的說明和備註資訊

在mysql下執行完下面這個建表語句後。 如何從資料字典中,檢索出這個表的字段的相關資訊?

drop table if exists test_table;

create table test_table(

test_id int not null auto_increment primary key comment 『主鍵(自增長)』,

test_key varchar(10) not null comment 『種類』,

test_value varchar(20) not null comment 』數值』,

test_type int not null comment 『內部型別』,

test_belongto int comment 『從屬關係』 ,

test_grade int default 1 comment 』等級』,

test_remark varchar(50) comment 『備註』,

test_visible bit default 1 comment 『是否可見』

)comment = 『測試表』;

答案是:

select

column_name as `列名`,

data_type as `資料型別`,

character_maximum_length as `字元長度`,

numeric_precision as `數字長度`,

numeric_scale as `小數字數`,

is_nullable as `是否允許非空`,

case when extra = 『auto_increment』

then 1 else 0 end as `是否自增`,

column_default as `預設值`,

column_comment as `備註`

from

information_schema.columns

where

table_name=』test_table』;

mysql資料庫一些常規操作

1.為指定mysql使用者指定表授權 grant select,insert,update,delete on testdb.orders to dba localhost 2.檢視當前mysql所有使用者 select distinct concat user user,host,as query...

操作mysql資料庫的一些命名

一 開啟資料庫 1.1 開啟命令列輸入 mysql u root p 1.2 root是本地資料庫的使用者名稱,然後輸入資料庫的密碼進入。二 資料庫操作 2.1 建立乙個資料庫 create database 資料庫名 2.2 檢視當前有哪些資料庫 show databases 2.3 更改資料庫字...

一些資料庫的操作

建立乙個資料庫 create database database name 刪除乙個資料庫 drop database database name 顯示資料庫 show databases 進入某個資料庫 use database name 建立乙個資料表 create table database...