MySQL additions and deletions to change the common syntax

Source: Internet
Author: User
Classification of SQL statements by function (definition, manipulation, control, query)
DDL data Definition language, defining tables, libraries, views
DML Add, modify, and delete operations on data table records
DCL authorization, transaction control, conditional judgment
DQL (not a category given by the organization) Data Sheet record query
That is, the creation, deletion, modification of the database, Gen, delete, modify the table, etc. (belongs to the DDL statement)
Adding and deleting Data insert Delete update (belongs to DML statement) (truncate delete) belongs to DDL
Query for data table records (belongs to DQL statement)
1. Creating a database creates a separate database for each software system:
Syntax: CREATE database name; (CREATE database with database server default character set)
Complex syntax Create database name character Set character set collate comparison rules;
For example, create a database called MYDB1. Create Database mydb1;
Create a MYDB2 database that uses the UTF8 character set. Create database mydb2 character set UTF8;
Create a MYDB3 database that uses the UTF8 character set and with the proofing rules. Create database mydb3 character set UTF8 collate utf8_bin;
Add: Each time a database is created, a folder is generated in the data store directory, and Db.opt holds the default character set and proofing rules for each folder
2. Querying the Database
show databases; -----View all databases
Show create database name; ------Viewing Data encoding sets
3. Delete Database
Syntax: drop database name;
For example: View all databases in the current database server show databases;
View the definition information for the MYDB2 database created earlier show create Database mydb2;
Delete the MYDB1 database that you created earlier, drop DB mydb1;
4. Modify the database encoding set
Syntax: ALTER DATABASE name character Set character set collate comparison rules;
For example: Modify the MYDB2 character set to GBK; ALTER DATABASE MYDB2 character set GBK;
Toggle Current Usage Database: Use database name
View currently in use database: select databases ();
Note: All database-related operation statements belong to the DDL statement
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.