Simply review the MySQL command-line operation

Source: Internet
Author: User

After the cmd command to enter the database, you need to manually do some operations on the database

Create a database plus a semicolon

MySQL>Createdatabase myfirstdatabase;

View the database you created plus s and semicolons

MySQL>show Databases;

Select the database plus semicolon to use

MySQL> use myfirstdatabase;

Create a database table plus a semicolon, and add character formatting UTF8

MySQL>createtable  table_name (        >varchar(20  ),        >varchar(+),        >int );

View tables plus s and semicolons in the database

MySQL>show Tables;

Database operations Select, INSERT, UPDATE, delete

SelectCode,name,age fromtable_name;Insert  intoTABLE_NAME ('0001','Zhang Mowgli', at);Updatetable_nameSetName='Zhang Trixan' whereCode='0001';Delete  fromtable_namewhereCode='0001';

The delete operation is still a little bit different from the ms-sql.

View table Design

MySQL>desc table_name;

Add a table field plus a semicolon;

MySQL>altertableaddvarchar;

Modify a field in a table

MySQL>altertablevarchar();

To delete a column in a table

MySQL>altertabledrop address;

A field in a table is set as the primary key

MySQL>altertableaddprimarykey (code);

A field in a table joins a normal index, unique index keyword unique, full-text index fulltext, multi-column index

MySQL>alter  tableaddindex index_name (Codel);
MySQL>altertableaddindex index_name (code,name);

Simply review the MySQL command-line operation

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.