Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Search | Email

第 4 章 DDL - Data Definition Language

目錄

4.1. 資料庫管理(Database)
4.1.1. create
4.1.2. drop
4.1.3. Alter
4.1.4. Rename
4.1.5. CHARACTER
4.1.6. show create database
4.2. 表管理(Table)
4.2.1. 數據類型
4.2.1.1. SET 集合類型
4.2.2. create table ... select
4.2.3. modifiy table
4.2.4. TEMPORARY Table
4.2.5. Collate
4.2.6. CHARACTER
4.2.7. DEFAULT
4.2.7.1. AUTO_INCREMENT
4.2.7.2. 表存儲位置(DATA DIRECTORY)
4.2.8. KEY
4.2.8.1. PRIMARY KEY
4.2.9. COMMENT
4.2.10. Engine
4.2.10.1. FEDERATED
4.2.10.2. BLACKHOLE
4.3. Partitioning
4.3.1. RANGE
4.3.2. LIST
4.3.3. HASH
4.3.3.1. LINEAR HASH
4.3.4. KEY分區
4.3.5. Subpartitioning
4.3.6. 分區管理
4.3.6.1. 新增分區
4.3.6.2. 刪除分區
4.3.6.3. 重建分區
4.3.6.4. 分區維護
4.3.7. EXPLAIN PARTITIONS
4.3.8. SHOW CREATE TABLE
4.3.9. INFORMATION_SCHEMA.partitions 表
4.3.10. 分區數據操作
4.4. Index
4.4.1. SHOW INDEX
4.4.2. CREATE INDEX
4.4.3. DROP INDEX
4.4.4. rebuild
4.5. 外鍵(Foreign Key)
4.5.1. FOREIGN KEY (RESTRICT)
4.6. 視圖(View)
4.7. 存儲過程(PROCEDURE)
4.7.1. 存儲程序
4.7.2. 函數
4.8. 觸發器(Trigger)
4.8.1. create trigger
4.8.1.1. Update 更新出發
4.8.1.2. Delete 刪除出發
4.8.1.3. Insert 插入出發
4.8.2. drop trigger
4.8.3. show triggers
4.8.4. EXAMPLE
4.8.4.1. BEFORE/AFTER
4.8.4.2. UUID
4.8.4.3. CALL PROCEDURE
4.9. 事件調度器(EVENT)
4.9.1. 啟用 EVENT
4.9.2. 創建 EVENT
4.9.3. 禁用/啟用
4.9.4. show events

4.1. 資料庫管理(Database)

4.1.1. create

Creating a UTF-8 database

CREATE DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
			

Create a UTF-8 database with binary UTF-8 collation.

CREATE DATABASE dbname CHARACTER SET utf8 COLLATE utf8_bin;
			

4.1.2. drop

DROP DATABASE db_name;
			

4.1.3. Alter

ALTER DATABASE dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
			

4.1.4. Rename

RENAME {DATABASE | SCHEMA} db_name TO new_db_name;
			

before 5.0 version

[neo@development ~]$ mysqldump -uroot -pchen db_old | mysql -uroot -pchen db_new
			

4.1.5. CHARACTER

			
ALTER DATABASE <database_name> CHARACTER SET utf8;
			
			

4.1.6. show create database

			
mysql> show create database dbname;
+----------+-------------------------------------------------------------------+
| Database | Create Database                                                   |
+----------+-------------------------------------------------------------------+
| dbname   | CREATE DATABASE `dbname` /*!40100 DEFAULT CHARACTER SET utf8 */   |
+----------+-------------------------------------------------------------------+
1 row in set (0.00 sec)