mysql DROP DATABASE刪除數據庫與創建數據庫create database
DROP DATABASE [IF EXISTS] db_name
DROP DATABASE 移除數據庫是的所有表並刪除數據庫。如果你在一個符號鏈接(symbolic link)數據庫上執行一個 DROP DATABASE,鏈接與原始數據庫均會被刪除。要非常小心地使用這個命令!
DROP DATABASE 返回從數據庫目錄下刪除的文件數目。通常,它是表的數目的三倍,因為第張表通常對應於一個 “.MYD” 文件、一個 “.MYI” 文件和一個 “.frm” 文件。
DROP DATABASE 命令從給定的數據庫目錄下移除以下列為擴展名的所有文件:
擴展名 擴展名 擴展名 Ext
.BAK .DAT .HSH .ISD
.ISM .ISM .MRG .MYD
.MYI .db .frm
所有包含兩個數字的子目錄(RAID 目錄)也同樣被刪除。
在 MySQL 3.22 或以後的版本中,你可以使用關鍵詞 IF EXISTS 以防止如果數據庫不存在時發生錯誤。
你也可以使用 mysqladmin 移除數據庫。查看章節 4.8 MySQL 客戶端腳本和實用程序。
6.5.3 CREATE TABLE 句法
CREATE [TEMPORARY] TABLE
[IF NOT EXISTS] tbl_name [(create_definition,...)] [table_options]
[select_statement]
or
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
LIKE old_table_name;
create_definition:
col_name type [NOT NULL | NULL] [DEFAULT default_value]
[AUTO_INCREMENT] [PRIMARY KEY]
[reference_definition]
or PRIMARY KEY (index_col_name,...)
or KEY [index_name] (index_col_name,...)
or INDEX [index_name] (index_col_name,...)
or UNIQUE [INDEX] [index_name] (index_col_name,...)
or FULLTEXT [INDEX] [index_name] (index_col_name,...)
or [CONSTRAINT symbol] FOREIGN KEY [index_name]
(index_col_name,...) [reference_definition]
or CHECK (expr)
type:
TINYINT[(length)] [UNSIGNED] [ZEROFILL]
or SMALLINT[(length)] [UNSIGNED] [ZEROFILL]
or MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL]
or INT[(length)] [UNSIGNED] [ZEROFILL]
or INTEGER[(length)] [UNSIGNED] [ZEROFILL]
or BIGINT[(length)] [UNSIGNED] [ZEROFILL]
or REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]
or DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]
or FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]
or DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL]
or NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL]
or CHAR(length) [BINARY]
or VARCHAR(length) [BINARY]
or DATE
or TIME
or TIMESTAMP
or DATETIME
or TINYBLOB
or BLOB
or MEDIUMBLOB
or LONGBLOB
or TINYTEXT
or TEXT
or MEDIUMTEXT
or LONGTEXT
or ENUM(value1,value2,value3,...)
or SET(value1,value2,value3,...)
index_col_name:
col_name [(length)]
reference_definition:
REFERENCES tbl_name [(index_col_name,...)]
[MATCH FULL | MATCH PARTIAL]
[ON DELETE reference_option]
[ON UPDATE reference_option]
reference_option:
RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT
table_options:
TYPE = {BDB | HEAP | ISAM | InnoDB | MERGE | MRG_MYISAM
| MYISAM }
or AUTO_INCREMENT = #
or AVG_ROW_LENGTH = #
or CHECKSUM = {0 | 1}
or COMMENT = "string"
or MAX_ROWS = #
or MIN_ROWS = #
or PACK_KEYS = {0 | 1 | DEFAULT}
or PASSWORD = "string"
or DELAY_KEY_WRITE = {0 | 1}
or ROW_FORMAT= { default | dynamic | fixed | compressed }
or RAID_TYPE= {1 | STRIPED | RAID0 } RAID_CHUNKS=#
RAID_CHUNKSIZE=#
or UNION = (table_name,[table_name...])
or INSERT_METHOD= {NO | FIRST | LAST }
or DATA DIRECTORY="absolute path to directory"
or INDEX DIRECTORY="absolute path to directory"
select_statement:
[IGNORE | REPLACE] SELECT ... (Some legal select statement)
CREATE TABLE 以給定的名字在當前數據庫創建一個表。允許的表名規則在章節 6.1.2 數據庫、表、索引、列和別名 中被給出。如果沒有當前數據庫或表已經存在,一個錯誤將會發生。