mysql業務字典表 MySql常用字典表

2021-10-17 16:54:29 字數 3048 閱讀 5228

1、顯示資料庫列表

mysql>show databases;

說明:其中字典庫是:information_schema,其中常用字典表:

information_schema.schemata  --資料庫中所有資料庫資訊

information_schema.tables  --存放資料庫中所有資料庫表資訊

information_schema.columns  --所有資料庫表的列資訊

information_schema.statistics  --存放索引資訊

information_schema.user_privileges  --

information_schema.schema_privileges

information_schema.table_privileges

information_schema.column_privileges

information_schema.character_sets

information_schema.collations

information_schema.table_constraints

information_schema.key_column_usage ---存放資料庫裡所有具有約束的鍵資訊

information_schema.routines

information_schema.views  --存放所有檢視資訊

information_schema.triggers  --觸發器資訊

2、顯示當前連線的資料庫

mysql>select database();

3、顯示庫中的資料表:

mysql>use mysql;(指定mysql庫)

mysql>show tables;

4、顯示資料表的結構:

mysql>describe yourtablename;

說明:describe 可以簡寫成desc

5、建庫:

mysql>create database yourdbname;

6、建表:

mysql>create table yourtablename (columnname colunmtype, ...);

6、刪庫和刪表:

mysql>drop database yourdbname;

mysql>drop table yourtablename;

7、退出

mysql>exit

或mysql>quit

8、連線資料庫

mysql -h主機位址 -u使用者名稱 -p密碼

如:c:\users\administrator>mysql -hlocalhost -uroot -proot

welcome to the mysql monitor.  commands end with ; or \g.

your mysql connection id is 7

server version: 5.5.17 mysql community server (gpl)

oracle is a registered trademark of oracle corporation and/or its

affiliates. other names may be trademarks of their respective

owners.

type 'help;' or '\h' for help. type '\c' to clear the current input statement.

mysql>

9、字段型別

1.int[(m)] 型: 正常大小整數型別

2.double[(m,d)] [zerofill] 型: 正常大小(雙精密)浮點數字型別

3.date 日期型別:支援的範圍是1000-01-01到9999-12-31。mysql以yyyy-mm-dd格式來顯示date值,但是允許你使用字串或數字把值賦給date列

4.char(m) 型:定長字串型別,當儲存時,總是是用空格填滿右邊到指定的長度

5.blob text型別,最大長度為65535(2^16-1)個字元。

6.varchar型:變長字串型別

10、啟用、禁用外來鍵約束

set foreign_key_checks='off';

set foreign_key_checks='on';

11、顯示建表sql

show create table 

12、顯示當前資料庫版本

select version();

13、顯示當前登入使用者

select user();

14、檢視指定表的索引資訊

show index from 表名稱

補充說明:mysql5中,關於索引的字典表是statistics,其中列collation表示索引的排序方式,值有2種,a表示公升序,null表示無分類。mysql5中,索引儲存的排序方式是asc的,沒有desc的索引。雖然索引是asc的,但是也可以反向進行檢索,就相當於desc了。如果您在order by 語句中使用了 desc排序,mysql確實會反向進行檢索。在理論上,反向檢索與正向檢索的速度一樣的快。但是在某些作業系統上面,並不支援反向的read-ahead預讀,所以反向檢索會略慢。由於設計的原因,在myisam引擎中,反向的檢索速度比正向檢索要慢得多。

其他1、create table cc_weibo_bak (select * from cc_weibo)

2、insert into cc_weibo_bak(uid,content) select uid ,concat('hello1 ',nick_name) from uc_users;

3、select  fid  ,count(fid) as fans_count from uc_follow where fid in(select uid from uc_users where user_type=22) group by fid order by fans_count desc ;

4、show full processlist

5、show status

Mysql 業務 表 設計

mysql 表的設計需要從兩個方面進行 重要性 如果表設計的不好,sql語句再怎麼優化也沒用,主要避免多表join,大資料量用join可能會急劇變慢,因為笛卡爾積的緣故 邏輯設計 正規化設計 資料庫設計的第一大正規化 資料庫設計的第二大正規化 資料庫設計的第三大正規化 正規化設計的問題 完全符合正規...

MySQL建立日期字典表

建立表 create table dic date date date str date varchar 16 local date varchar 16 year int month int day int dayofyear int dayofmonth int weekofyear int w...

mysql字典 mysql常用字典表 完整版

本節內容 mysql資料庫中的常用字典表。1 顯示資料庫列表 示例 mysql show databases 說明 其中字典庫是 information schema,其中常用字典表 information schema.schemata 資料庫中所有資料庫資訊 information schema...