Home > Database > Mysql Tutorial > Mysql's common syntax for adding, deleting, modifying and querying

Mysql's common syntax for adding, deleting, modifying and querying

无忌哥哥
Release: 2018-07-18 09:52:13
Original
2207 people have browsed it

SQL statement classification is classified by function (definition, manipulation, control, query)
DDL data definition language, defines tables, libraries, views
DML adds, modifies and deletes data table records
DCL Authorization, transaction control, conditional judgment
DQL (not classified by W3C organization) Data table record query
That is, creating numbers, deleting, modifying databases, creating numbers, deleting, modifying tables, etc. (belonging to DDL statements)
Insert delete update (belongs to DML statement) (truncate delete) belongs to DDL
Query of data table records (belongs to DQL statement)
1. Creating a database will create a separate database for each software system:
Syntax: create database database name; (create database using the default character set of the database server)
Complex writing method create database database name character set character set collate comparison rules;
For example: create a database named mydb1. create database mydb1;
Create a mydb2 database using the utf8 character set. create database mydb2 character set utf8;
Create a mydb3 database using the utf8 character set with proofreading rules. create database mydb3 character set utf8 collate utf8_bin;
Supplement: Each time a database is created, a folder is generated in the data storage directory, and db.opt exists in each folder to store the default character set and collation rules
2. Query database
show databases; ----- View all databases
show create database database name; ------ View data encoding set
3. Delete database
Syntax: drop database database Name;
For example: View all databases in the current database server show databases;
View the definition information of the previously created mydb2 database show create database mydb2;
Delete the previously created mydb1 database drop database mydb1;
4. Modify the database encoding set
Syntax: alter database database name character set character set collate comparison rule;
For example: modify the mydb2 character set to gbk; alter database mydb2 character set gbk;
Switch the currently used database : use database name
View the database currently in use: select database();
Note: All database-related operation statements are DDL statements

The above is the detailed content of Mysql's common syntax for adding, deleting, modifying and querying. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template