Home > Database > Mysql Tutorial > body text

cmd command line mode to operate the database (tables, fields, data addition, deletion, modification and query)

青灯夜游
Release: 2018-10-19 15:52:48
forward
7097 people have browsed it

The content of this article is to introduce the method of operating the database (table, field, data addition, deletion, modification and query) in cmd command line mode. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

1. View databases, tables, data fields, data

1 First configure the environment variables to enter mysql or open the mysql command line or mysql visualization tool through one-click integration tools Open the command line

#Enter such an interface Different machines operate differently, so I won’t describe them one by one here

2 View all current databases

show  databases;
Copy after login

3 Select (enter) database

use   数据库名;
Copy after login

4 View all tables in the current database

show tables;
Copy after login

5 View the field structure of a table

desc  表明;
Copy after login

6 Query table data

select * from  表名;
Copy after login

2. Create a new database, data table (table), data (add data)

1 Create a new database

create  database  数据库名;
Copy after login

Enter Create a new database and create a table

2 Create a new table

CREATE TABLE 表名 (
    字段名字   数据类型  修饰
)
Copy after login

Note that there must be at least one field. The modification and data type will not be explained in detail here. The keywords are in capital letters and are used between fields. The last line is not used. .

3 Add data

  insert into 表名 valuse(值,值);
Copy after login

##3. Modify the data table and modify the data

1 Modify the data table

(1) alter table table name add field name type modification [added columns are at the end of the table]

(2) alter table table name add field name type modification after a certain column [add new column after a certain column]

(3) alter table table name add field Name type parameter first【Add new column to the front】

2 Modify data

update user set name=新值 where
Copy after login

3 Modify database Different versions have different methods

RENAME database oldname TO newname; (The latest version 5.2 and above seems to have been abandoned, please refer to other methods if necessary)

The version has been abandoned

4. Delete database, data table, data

1 Delete database

drop database 数据库名;
Copy after login

2 Delete data table

 drop  table  表名
Copy after login

3 Delete data

 delete  from  表名 where;
Copy after login

Summary: The above is the entire content of this article, I hope it can be helpful to everyone Learning helps. For more related tutorials, please visit

MySQL Video Tutorial!

The above is the detailed content of cmd command line mode to operate the database (tables, fields, data addition, deletion, modification and query). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!