Basic operation of MySQL based on Linux operating system (ii)

Source: Internet
Author: User

Basic operation of Mysql based on Linux operating system (ii)

Let's start by creating a library with the following steps:

    • First create a library, command:

#create database Wu;

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/8E/97/wKioL1jGW_ORAwqXAAAJEtICOtY994.png-wh_500x0-wm_ 3-wmp_4-s_3011650503.png "title=" 99.PNG "alt=" Wkiol1jgw_orawqxaaajeticoty994.png-wh_50 "/>

    • View the new library, command :

#show databases;

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/8E/99/wKiom1jGXEDBUikkAAAQNcz2ch8554.png-wh_500x0-wm_ 3-wmp_4-s_973247348.png "title=" 100.PNG "alt=" Wkiom1jgxedbuikkaaaqncz2ch8554.png-wh_50 "/>

    • using the Wu database, create a table inside, the table name is test, command:

#use Wu;

# CREATE TABLE test (ID int (3), name char (10));

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M00/8E/97/wKioL1jGXHPgjzSaAAAKOps3h-8698.png-wh_500x0-wm_ 3-wmp_4-s_950398477.png "title=" 101.PNG "alt=" Wkiol1jgxhpgjzsaaaakops3h-8698.png-wh_50 "/>

to create a table format: Create table table name (table column name 1 data type, table column name 2 data type . ..... )

    • View the Test table below, command:

#show CREATE TABLE test;

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/8E/99/wKiom1jGXLPyjT0NAAAdAcODK3A668.png-wh_500x0-wm_ 3-wmp_4-s_1578020786.png "title=" 102.PNG "alt=" Wkiom1jgxlpyjt0naaadacodk3a668.png-wh_50 "/>

    • to add content to the test table, command:

# INSERT INTO test values (1,teng);

# SELECT * FROM test;

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/8E/99/wKiom1jGXPbBXAUYAAAX43Nf3dM311.png-wh_500x0-wm_ 3-wmp_4-s_3986080035.png "title=" 103.PNG "alt=" Wkiom1jgxpbbxauyaaax43nf3dm311.png-wh_50 "/>

Add only one content, command:

# INSERT INTO Test (ID) values (2);

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/8E/99/wKiom1jGXWuRo9_pAAAUtlTe_II950.png-wh_500x0-wm_ 3-wmp_4-s_2605407202.png "title=" 104.PNG "alt=" Wkiom1jgxwuro9_paaautlte_ii950.png-wh_50 "/>

    • to update the contents of the test table, command:

# Update test set name= ' Fei ' where id=2;

# SELECT * FROM test;

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/8E/99/wKiom1jGXaCjiz81AAAZI1pwXqk167.png-wh_500x0-wm_ 3-wmp_4-s_504238218.png "title=" 105.PNG "alt=" Wkiom1jgxacjiz81aaazi1pwxqk167.png-wh_50 "/>

    • To delete the contents of a table, command:

# Delete from test where id=2;

# SELECT * FROM test;

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/8E/99/wKiom1jGXc-ys76rAAATJdI9lMQ747.png-wh_500x0-wm_ 3-wmp_4-s_2020147199.png "title=" 106.PNG "alt=" Wkiom1jgxc-ys76raaatjdi9lmq747.png-wh_50 "/>

    • To clear the contents of a table, command:

#truncate table test;

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/8E/99/wKiom1jGXfTxEyBTAAANavOAfng203.png-wh_500x0-wm_ 3-wmp_4-s_3433495645.png "title=" 107.PNG "alt=" Wkiom1jgxftxeybtaaanavoafng203.png-wh_50 "/>

    • To delete a table, command:

#drop table test;

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/8E/97/wKioL1jGXiTQdmiFAAAQoaow1Lc869.png-wh_500x0-wm_ 3-wmp_4-s_3660270887.png "title=" 108.PNG "alt=" Wkiol1jgxitqdmifaaaqoaow1lc869.png-wh_50 "/>

    • To delete a library, command:

#drop databases Wu;

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M00/8E/97/wKioL1jGXlCAW-OIAAA0Mc61LlA517.png-wh_500x0-wm_ 3-wmp_4-s_2295862090.png "title=" 109.PNG "alt=" Wkiol1jgxlcaw-oiaaa0mc61lla517.png-wh_50 "/>

Note: When deleting the library and updating, the data remember to back up!

This article is from the "Wu Fei" blog, please be sure to keep this source http://wutengfei.blog.51cto.com/10942117/1905963

Basic operation of MySQL based on Linux operating system (ii)

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.