Home | 简体中文 | 繁体中文 | 杂文 | Search | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 作品与服务 | Email

第 40 章 DDL - Data Definition Language

目录

40.1. 数据库管理(Database)
40.1.1. create
40.1.2. drop
40.1.3. Alter
40.1.4. Rename
40.1.5. CHARACTER
40.1.6. show create database
40.2. 表管理(Table)
40.2.1. 数据类型
40.2.1.1. SET 集合类型
40.2.2. create table ... select
40.2.3. modifiy table
40.2.4. TEMPORARY Table
40.2.5. Collate
40.2.6. CHARACTER
40.2.7. DEFAULT
40.2.7.1. AUTO_INCREMENT
40.2.7.2. 表存储位置(DATA DIRECTORY)
40.2.8. KEY
40.2.8.1. PRIMARY KEY
40.2.9. COMMENT
40.2.10. Engine
40.2.10.1. FEDERATED
40.2.10.2. BLACKHOLE
40.3. Partitioning
40.3.1. RANGE
40.3.2. LIST
40.3.3. HASH
40.3.3.1. LINEAR HASH
40.3.4. KEY分区
40.3.5. Subpartitioning
40.3.6. 分区管理
40.3.6.1. 新增分区
40.3.6.2. 删除分区
40.3.6.3. 重建分区
40.3.6.4. 分区维护
40.3.7. EXPLAIN PARTITIONS
40.3.8. SHOW CREATE TABLE
40.3.9. INFORMATION_SCHEMA.partitions 表
40.3.10. 分区数据操作
40.4. Index
40.4.1. SHOW INDEX
40.4.2. CREATE INDEX
40.4.3. DROP INDEX
40.4.4. rebuild
40.5. 外键(Foreign Key)
40.5.1. FOREIGN KEY (RESTRICT)
40.6. 视图(View)
40.7. 存储过程(PROCEDURE)
40.7.1. 存储程序
40.7.2. 函数
40.8. 触发器(Trigger)
40.8.1. create trigger
40.8.2. drop trigger
40.8.3. show triggers
40.8.4. EXAMPLE
40.8.4.1. BEFORE/AFTER
40.8.4.2. UUID
40.8.4.3. CALL PROCEDURE
40.9. 事件调度器(EVENT)
40.9.1. 启用 EVENT
40.9.2. 创建 EVENT
40.9.3. 禁用/启用
40.9.4. show events

40.1. 数据库管理(Database)

40.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;
			

40.1.2. drop

DROP DATABASE db_name;
			

40.1.3. Alter

ALTER DATABASE dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
			

40.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
			

40.1.5. CHARACTER

			
ALTER DATABASE <database_name> CHARACTER SET utf8;
			
			

40.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)
			
			
comments powered by Disqus