当前位置:网站首页>数据库的常用命令1
数据库的常用命令1
2022-07-27 16:08:00 【zh_Tnis】
1.Win+R的MySQL的启用和关闭。
- 启用:net start mysql
- 关闭:net stop mysql

2.MySQL的登录和退出。
- mysql -uroot -p -P3306
- password:密码
- 退出:exit或者quit

3.服务器版本、日期、用户显示
- 显示服务器版本:SELECT VERSION();
- 显示当前日期:SELECT NOW();
- 显示当前用户:SELECT USER();
4.常看数据库。
- show databases;

5.创建数据库。
- create database demo1;

6.if not exits的使用和错误创建的显示。
- 首先我们上边已经创建了demo1这个库,当我们再次创建demo1时将会报错,这时候我们可以使用if not exits

7.查看数据库的编码格式。
- show create database database_name;

8.创建数据库时对数据库的编码格式进行更改。
- create database database_name character set gbk;
9.把已创建的数据库编码进行修改。
- alter database database_name character set gbk;

10.对已创建的库进行删除。
- drop database database_name;

11.关于数据库语言的分类。
- DDL(数据定义语言):用来定义数据库的对象,如数据表、视图、索引等
- DML(数据操纵语言):在数据库表中更新、增加和删除记录
- DCL(数据控制语言):指用于设置用户权限和控制事务语句
- DQL(数据查询语言)(***):数据表记录的查询
12.表的操作。
- 行:记录
- 列:字段
13.进入一个库。
- use database_name;

14.常看库下存在哪些表。
- show tables;

15.创建表。
- create table table_name1(
- age int unsigned,
- username varchar(20),
- salary float(9.2),
- );

16.查看表结构。
- 1:show columns from table_name;
- 2:desc table_name;

17.往表中插入数据。
- 1:insert table_name (col_name1,col_name2,col_name3...) values (col_key1,col_key2,col_key3...);
- 2:insert table_name values (col_key1,col_key2,col_key3...);
- 3:insert table_name (col_name1,col_name2) values (col_key1,col_key2);

18.查询表中的记录。
- select * from table_name;

19.删除表的记录。
- 删除指定字段的记录:delete from table_name where col_name=col_key;
- 删除表中全部字段的记录:delete from table_name;

20.使表能输出中文,有时我们会发现插入中文数据后,使用select * from table_name无法输出中文。
- set character_set_results=gb2312;

21.使表中输出的记录能够对齐。
- charset gbk;

边栏推荐
- jpa连接数据库password字段BLOB
- Evaluation index of machine learning (I) -- regression evaluation index
- Convolutional neural network -- Translation of yolov1 thesis
- 联发科首款5G SoC来了!A77+G77+APU3.0,11月26日正式发布!
- [learning notes] the implementation principle of the ordered set Zset in redis - skip table
- CFA exam registration instructions
- Backup table recovery table
- 又一个时代的终结!
- Exciting collection of new features released by salesforce
- 收藏!0 基础开源数据可视化平台 FlyFish 大屏开发指南
猜你喜欢

数据库的常用命令2

Convolutional neural network -- from r-cnn, fast r-cnn to fast r-cnn, mask r-cnn

Knowing things by learning | app slimming down, the way of safety reinforcement under the new generation AAB framework

多表查询

Salesforce File Share and Security

浅论分布式训练中的recompute机制

The Ministry of industry and information technology re governs data security, and Netease Yidun "privacy compliance" keeps the bottom line of enterprise operation

vue使用keep-alive实现页面缓存

Machine learning: IOU of concept understanding

Operation of simulated examination platform for 2022 low voltage electrician examination questions
随机推荐
Year end summary template
登录页面tableLayout(表格布局)
Redis网红高频面试题三连:缓存穿透?缓存击穿?缓存雪崩?
Resolve merge fields in salesforce
Understand JVM language
Profiles vs Permission Sets
Operation of simulated examination platform for 2022 low voltage electrician examination questions
多线程导入数据并生成错误文件用redis存储
Es query limit 10000 data solutions
How can we carry out NLP cross language knowledge transfer?
vue使用keep-alive实现页面缓存
Telecommuting can be easily realized in only three steps
最新大厂高级面试题 必备
Buffer的只读模式
Salesforce runs all test classes and gets coverage reports
Multi thread implementation loop
请教大神一个问题 flinkcdc,同步mysql中的datetime字段会变为时间戳 有人遇到过吗
What's the use of games| Game application value research case collection
给程序界面增加音乐,加载背景照片。
Find redundant duplicate records in the table, delete and retain the minimum one