Mysql drop database delete database and create DATABASE

Source: Internet
Author: User
Tags mysql drop database

Mysql drop database delete database and create DATABASE

Drop database [if exists] db_name
Drop database remove all tables in the DATABASE and delete the DATABASE. If you execute a drop database on a symbolic link DATABASE, the link and the original DATABASE will be deleted. Use this command with caution!

Drop database returns the number of files deleted from the DATABASE directory. Generally, it is three times the number of tables, because the first table usually corresponds to a ". MYD" file, a ". MYI" file, and a ". frm" file.

The drop database Command removes all files with the following extensions from the given DATABASE directory:

Extension: Ext
. BAK. DAT. HSH. ISD
. ISM. ISM. MRG. MYD
. MYI. db. frm

All subdirectories (RAID Directories) that contain two numbers are also deleted.

In MySQL 3.22 or later versions, you can use the keyword if exists to prevent errors IF the database does not exist.

You can also use mysqladmin to remove a database. See section 4.8 MySQL client scripts and utilities.

6.5.3 create table syntax

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 creates a TABLE in the current database with the given name. The table naming rules are given in section 6.1.2 databases, tables, indexes, columns, and aliases. If no database or table already exists, an error will occur.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.