Basic mysql operations

Source: Internet
Author: User
1. MySQL database operation 1. createdatabase syntax for creating database commands: createdatabase database name. When creating a database, the database name has the following rules: 1. It cannot be the same as other databases; otherwise, an error occurs. 2. The name can consist of any letter, Arabic number, underline, and $.

1. MySQL database operation 1. create database syntax for creating database commands: create database name. When creating a database, the database name has the following rules: 1. It cannot be the same as other databases; otherwise, an error occurs. 2. The name can consist of any letter, Arabic number, underline, and $.

1. MySQL database operations

1. create database for creating database commands

Syntax format: create database name.

When creating a database, the database naming rules are as follows:

1. It cannot be renamed with other databases; otherwise, an error will occur.

2. The name can be composed of any letter, Arabic number, underline, and $. It can start with any of the above characters, but cannot start with a separate number. Otherwise, the database and value may be confused.

3. The name can contain up to 64 strings, while the alias can contain up to 256 strings.

4. the MySQL keyword cannot be used as the database name or table name.


2. query database commands-show databases;

Syntax format: show databases;

3. Select use for database commands

Syntax format: use Database Name;

Iv. drop database for data deletion commands

Syntax format: drop database Name

2. MySQL Data Table operations

1. create table

Syntax format: create table data table name;

Parameters of the create table statement:

Temporary Keyword: Indicates creating a temporary table

If not exists Keyword: Avoid MySQL report errors when the table exists

Create_definition: column attribute of the created table

Table_option: Table Parameters

Select_statement: Used to quickly create a table.


Create_definition attribute parameter description

Col_name: column name of the table

Type: Field type

Not null | null: whether it is null

Default default_value: default Value

Auto_increment: automatic number

Primary key: primary key

Reference_definition: Field comment

2. view the show columns or describe commands of a table

Syntax format: show columns from data table name

Show columns from data table name. Database Name


Iii. alter table

Syntax format: alter table data table name: Modify table attributes;


4. rename a table

Syntax format: rename table data table name to data table name s


5. drop table for table deletion commands

Syntax format: drop table data table name

3. MySQL statement operations

1. insert a record command

Syntax format: insert into data table name (col_name) values (value );

Ii. select for data record query commands

Syntax format: select * from data table name;

4. update the modification record command

Syntax format: update data table name set column name = value where Condition

5. delete a record command

Syntax format: delete from data table name where Condition

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.