MySQL drop database deleting databases and creating databases Create database

Source: Internet
Author: User
Tags mysql client mysql drop database create database

MySQL drop database deleting databases and creating databases Create database

DROP DATABASE [IF EXISTS] Db_name
The drop database removes all tables from the database, and deletes the databases. If you execute a DROP database on a symbolic link (symbolic link), both the link and the original database are deleted. Use this command very carefully!

The drop database returns the number of files deleted from the database directory. Typically, it is three times times the number of tables because the first table usually corresponds to one. MyD "file, one". Myi "File and a. frm" file.

The DROP database command removes all files from the given database directory that are listed as extensions:

Extension extension Ext
. Bak. Dat. HSH. Isd
. Ism. Ism. MRG. MyD
. Myi. db. frm

All subdirectories that contain two digits (RAID directories) 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 the database. View Chapter 4.8 MySQL client script 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 | A | 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 permitted table name rules are given in the chapters 6.1.2 databases, tables, indexes, columns, and aliases. If there is no current database or the table already exists, an error will occur.

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.