Title

MySQL之旅(4) MySQL常用指令

1·服务启动指令:

net start mysql

2·停止服务指令:

net stop mysql

3·登录指令:

mysqle -u root -p

4·退出指令:

exit

5·修改密码指令:

ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘修改后的密码’

6·刷新权限指令:

FLUSH PRIVILEGES

7·添加末列指令:

alter table TABLE_NAME add column NEW_COLUMN_NAME varchar(20) not null;

8·添加到某列后面指令:

alter table TABLE_NAME add column NEW_COLUMN_NAME varchar(20) not null after COLUMN_NAME;

9·添加到首列指令:

alter table TABLE_NAME add column NEW_COLUMN_NAME varchar(20) not null first;

10·插入一行及多行指令:

INSERT INTO table_name ( field1, field2,...fieldN ) VALUES ( value1, value2,...valueN );
INSERT INTO table_name ( field1, field2,...fieldN ) VALUES ( value1, value2,...valueN ), ( value1, value2,...valueN ), ( value1, value2,...valueN ), ( value1, value2,...valueN );

11·查询读取指令:

select * from TABLE_NAME;

12·显示数据指令:

show full columns from TABLE_NAME;

13·应用数据库指令:

use TABLE_NAME;

14·删除数据指令:

drop database <数据库名>;
DROP TABLE table_name ;

15·创建数据指令:

CREATE DATABASE 数据库名;
CREATE TABLE table_name (column_name column_type);

16·数据去重指令及实例:传送门

...

end!

posted @ 2021-06-29 10:46  谈亦行  阅读(52)  评论(1编辑  收藏  举报