当前位置:网站首页>数据库的常用命令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;

边栏推荐
- Resolve merge fields in salesforce
- [learning notes] Lombok's @builder annotation
- Salesforce Dynamic Forms
- Marvell公布旗下Arm服务器芯片路线图,下一代性能将比ThunderX2高两倍
- JRS-303用法
- Knowing things by learning | app slimming down, the way of safety reinforcement under the new generation AAB framework
- CPU introduction
- 图形界面编程
- Redis网红高频面试题三连:缓存穿透?缓存击穿?缓存雪崩?
- VSS tip: search all checked out files (search checked out files according to users)
猜你喜欢

Convolutional neural network -- Introduction to FPN (feature pyramid networks)

查看端口PID及结束进程

使用分布式框架WCF出现的BUG记录

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

What's the use of games| Game application value research case collection

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

What every Salesforce developer should know about Dates and Times in Apex
![[Southwest University] information sharing of postgraduate entrance examination and re examination](/img/15/298ea6f7367741e1e085007c498e51.jpg)
[Southwest University] information sharing of postgraduate entrance examination and re examination

Interview FAQs 12

XStream reports an error abstractreflectionconverter$unknownfield exception when parsing XML
随机推荐
图形界面编程
Getting started with typora: the most complete tutorial in the whole network
Big gap? Requirements and conditions for candidates with different academic qualifications to take the postgraduate entrance examination
【学习笔记】lombok的@Builder注解
Dbeaver connection MySQL error: the server time zone value 'Ö Ð¹ ú±ê ×¼ ʱ ¼ ä‘ is unrecognized or represents more than
[Southwest University] information sharing of postgraduate entrance examination and re examination
Year end summary template
Golang Chan implements mutual exclusion
给程序界面增加音乐,加载背景照片。
TCP connection status identification (syn, fin, ACK, PSH, RST, urg)
Local development using LWC in salesforce
EF框架简介
2022 high altitude installation, maintenance and removal of test question simulation test platform operation
Golang concurrent cache breakdown or merge request
You can't specify target table 'table name' for update in from clause error resolution in MySQL
Evaluation index of machine learning (II) -- classification evaluation index
Find redundant duplicate records in the table, delete and retain the minimum one
@Scheduled 和Quartz
GIS数据漫谈(五)— 地理坐标系统
Golang waits for a group of goroutines to complete with the return value (2)