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

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

青灯夜游
青灯夜游 forward
2018-10-19 15:48:44 7045browse

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;

3 Select (enter) database

use 数据库名;

4 View all tables in the current database

show tables;

5 View the field structure of a table

desc 表明;

6 Query table data

select * from 表名;

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

1 Create a new database

create database 数据库名;

Enter Create a new database and create a table

2 Create a new table

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

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(值,值);

##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

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 数据库名;

2 Delete data table

drop table 表名

3 Delete data

delete from 表名 where;

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!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete