MySQL database defines common operations

Source: Internet
Author: User
The database name is tentatively: DB
1. Create a database
Create DATABASE db default character set UTF8;

2. Using the database
Use DB;

3. Deleting a database
drop database db;

4. Modifying the character set of a database
ALTER DATABASE DB default CharSet UTF8;

5. View the statement that established the database
Show create database db;

6. Create a table to see its default values
CREATE table T (t int);

7. Create a table
CREATE TABLE T1 (
tid int unsigned not NULL auto_increment,
Tname varchar (+) NOT NULL,
Primary KEY (TID)
) auto_increment=201401;

8. Delete a table
drop table T1;

9. Delete multiple tables in bulk
drop table t1,t2,t3;

10. Modify the table name
Rename table T1 to student;

11. Modify the Type and field name of the fields in the table
ALTER TABLE student change tname sname varchar (+) not null;

12. Add a column
ALTER TABLE student add saddress varchar () after sname;

13. Delete Columns
ALTER TABLE student drop column saddress;

MySQL database defines common operations

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.