Common basic MySQL operations

Source: Internet
Author: User
No details about MySQL? # Common basic operations of the MySQL database SQL (StructuredQueryLanguage) Structured Query Language: * DDL (DataDefinitionLanguage) Data Definition Language * # create a database: createdatabase database name charsetutf8; # delete a database: dropdatabase database name; # display

No details about MySQL? # Common basic operations of the Structured Query Language (Structured Query Language) Structured Query Language in MySQL:/* Data Definition Language (DDL) */# create a database: create database 'database name' charset utf8; # delete a database: drop database 'database name'; # display

<无详细内容> MySQL
? # Common basic operations of the Structured Query Language (Structured Query Language) Structured Query Language in MySQL:/* Data Definition Language (DDL) */# create a database: create database 'database name' charset utf8; # delete database: drop database 'database name'; # display all databases: show databases; # use database 'database name '; # determine the currently used database: select database (); # desc 'table name' of a table structure in the database; # show the table creation statement show create table 'table name '; # create a table: create table 'table name' ('column name' 'column description', 'column name', 'column name '); # create table 'table name' ('column name' column description 'Primary key auto_increment, 'column name' 'column description ', 'column name' 'column description'); # delete a table: drop table 'table name'; # modify a table: alter table 'old table name' rename' new table name '; # add field alter table 'table name' add column 'column name' 'column description '; # modify the field "alter table" table name "change" old column name "new column name" "new column description"; # Delete the field "alter table" table name "drop column name" column name '; /* DML (Data Manipulation Language) Data operation Language */# insert into 'table name' ('field name, field name... ') values (' corresponding value, corresponding value... '); insert into' table name' values ('corresponding value, corresponding value... '); # update data Update' table name 'set' field name' = 'field value', 'field name' = 'field value '... where 'field name' = 'field value'; Update' table name'set' field name' = 'field value', 'field name' = 'field value '...; # delete Data from 'table name'; delete from 'table name' where 'field name' = 'field value';/* DQL (Data Queries Language) data Query Language */# query all select * from 'table name'; # query the required select 'field name', 'field name '... from 'table name'; # Alias query select 'field name', concat ('field name', 'field name') [as] 'Alias 'from' table name '; # where query select * from 'table name' where 'field name' like "_ 'value' %" # Aggregate Query select count (*) from 'table name '; # query the number of records select 'field name' from 'table name' order by 'field name' desc; # query select distinct 'field name' from 'table name' order by 'field name' asc in descending order; # duplicate query in ascending order # select avg ('field name') from 'table name' group by 'field name'; select avg (field name) as 'Alias ', 'Alias 'from 'field name' group by 'field name' having 'field name'> 0;/* DCL (Data Control Language) data Control Language * // * constraint */# primary key constraint alter table 'table name' add constraint primary key ('field name '); # unique constraint alter table 'table name' add constraint unique ('field name '); # foreign key constraint alter table 'table name' add constraint foreign key ('foreign key field name') references 'Primary table' ('Primary key field name ');

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.