MySQL database learning-3. Table creation, deletion, and change

Source: Internet
Author: User
Table Creation Create Table mytbl (ID int auto_increment not null, name char (10) Not null, birth date not null, wight int, sex Enum ('F', 'M ')); Create a table for the specified Database Engine Create Table mytbl (ID int auto_increment not null, name char (10) Not null, birth date not null, wight int, sex Enum ('F', 'M ')) Engine = memory ; Create temporary table Create Temporary Table mytbl (ID int auto_increment not null, name char (10) Not null, birth date not null, wight int, sex Enum ('F', 'M ')); Copy Data Table Structure (You can also create a temporary table as a copy. Create Temporary Table tblnew like tblold) Create Table tblnew like tblold copy data at the same time insert into tblnew select * From tblold Create a table from the query results Create Table tblnew select * From tblold Delete A data table Drop table tbl_nameddrop table tbl_name, tbl2_nameddrop table if exists tbl_nameddrop temporary table tbl_name Modify a data table

 

Modify the Data Type of a data column Alter table mytbl modify I mediumint unsignedalter table mytbl Chang I mediumint unsigned Modify the data type and character set of a data column Alter table mytbl modify I mediumint Character Set ucs2 Modify the storage engine of a data table Alter table mytbl engine = engine_name Rename a data table Alter table tbl_name Rename to new_tbl_namerename talbe tbl_name to new_tbl_name Rename multiple data tables
Rename talbe tbl_name to new_tbl_name, T1 to T2, T3 to T4 Move data tables to another database ALTER TABLE Db1. Tbl_name Rename Db2. New_tbl_namerename talbe Db1. Tbl_name Db2. New_tbl_name
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.