Case two, viewing the database
MySQL is a database management system that supports running multiple libraries, each of which is the equivalent of a container that holds many tables. Data exists in these tables, so viewing, creating, deleting libraries and tables is essential in your work.
One, view
1. See which libraries are in the current server
Use command: SHOW DATABASES; View library Information
650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M01/78/BF/wKioL1aCml2DsyNUAABu3Wde0s4574.jpg "title=" 6.jpg " alt= "Wkiol1acml2dsynuaabu3wde0s4574.jpg"/>
2. See which tables are currently in use in the library
Using the command: use MySQL; Switch to a table named MySQL using the use command
Use command: SHOW TABLES; View table Information
650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M01/78/C1/wKiom1aCm_bCDFBYAABr2aaUGBw890.jpg "title=" 7.jpg " alt= "Wkiom1acm_bcdfbyaabr2aaugbw890.jpg"/>
3. View the structure of the table
Use command: DESCRIBE mysql.user; MySQL is the library name and user is the table name.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/78/BF/wKioL1aCnyvxU_T9AAB4aw85JO8769.jpg "title=" 8.jpg " alt= "Wkiol1acnyvxu_t9aab4aw85jo8769.jpg"/>
Second, create and delete libraries and tables
1, create a new library
Using the command: Create database name;//creating a library named name
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M01/78/C1/wKiom1aCoAzS8K4eAAAZPTd-b6c817.jpg "title=" 9.jpg " alt= "Wkiom1acoazs8k4eaaazptd-b6c817.jpg"/>
2, create a new table
Command syntax: CREATE table table name (field 1 name type, field 2 name Type, ..., PRIMARY key (primary key name))
Using the command: use name;
CREATE TABLE Users (user_name char (+) not NULL, user_passwd char ("DEFAULT", PRIMARY KEY (user_name));
Create a table named users with field name 1 of user_name 16 bytes and cannot be empty. The field Name 2 is user_passwd 48 bytes, the default null type is used, and the primary key name is user_name.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/78/C0/wKioL1aCpKGRfYxoAAA5nwF8M-w904.jpg "title=" 10.jpg "alt=" Wkiol1acpkgrfyxoaaa5nwf8m-w904.jpg "/>
3, delete a table
Use the command: Drop table name.users;//delete the Users table in the name library
650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M01/78/C2/wKiom1aCq1qB0dFDAAAaa0CTsVM404.jpg "title=" 11.jpg "alt=" Wkiom1acq1qb0dfdaaaaa0ctsvm404.jpg "/>
4, delete a library
Use command: Drop database name;//delete name Library
650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M02/78/C0/wKioL1aCq9-hRVpgAAAZwPvl0VM649.jpg "title=" 12.jpg "alt=" Wkiol1acq9-hrvpgaaazwpvl0vm649.jpg "/>
This article is from the "New Start" blog, so be sure to keep this source http://yuanshuai.blog.51cto.com/10539781/1729801
MySQL basic command----view, create, delete libraries and tables in a Linux environment