当前位置:网站首页>Various usages of MySQL backup database to create table select and how many days are left
Various usages of MySQL backup database to create table select and how many days are left
2022-07-03 06:15:00 【Bobo AI leaves work】
Command line that must be remembered
mysql -u root -pmysql -h Host name (192.168.200.1) Fill in the host name you want to link -P 3306 Port number -p
Input password Accuracy in work use DOUBLE and DECIMAL Do not use float
Start the service
net start mysql
Close the service
net stop mysqlBackup database
stay dos( No MYSQL Next ) To execute under orders -B Represents the entire table
mysqldump -u root -p -B db02 > d:\\bak.sqlmysqldump -u root -p database db02 surface 2 > d:\\bak.sqlRemember to take the path
Recover database ( When entering MYSQL Give orders )
mysql -u -root -pSOURCE d:\\bak.sqlDelete database
DROP DATABASE db02Find database elements
SELECT * FROM users WHERE NAME=' Zhang San 'establish MySql surface ( Pay attention to the position of the table )
CREATE TABLE `bobo`(
id INT,
`name` VARCHAR(255),
`password` VARCHAR(255),
`birthday` DATE)
CHARACTER SET utf8 COLLATE utf8_bin ENGINE INNODB;Create table emp,char There should be characters in it , The difference between characters and bytes
CREATE TABLE `emp`(
id INT,
`name` VARCHAR(32),
sex CHAR(1),
brithday DATE,
entryday DATETIME,
job CHAR(32),
salary FLOAT,
`resume` TEXT) CHARSET utf8 COLLATE utf8_bin ENGINE INNODB;Write data to the table , Remember to add parameters (id,name,sex,date,datetime,zhiye,sarlary,resume)
INSERT INTO `emp`
VALUES('100',' Tang Bo ',' male ','1996-08-18','2019-11-11 11:12',' The programmer ','5000',
' I am a bobo');# increase image Column
# View table structure
DESC `emp`
modify job Table properties
# increase image Column
ALTER TABLE `emp` ADD image VARCHAR(32) AFTER RESUME
# View table structure
DESC `emp`
# modify job type by varchar(80) It is not empty by default
ALTER TABLE emp
MODIFY job VARCHAR(80) NOT NULL DEFAULT ''Delete table attributes
ALTER TABLE emp
DROP brithday;Modify the name of the table
RENAME TABLE emp TO eeemmpppChange column names
ALTER TABLE eeemmppp CHANGE `name` `user_name` VARCHAR(50) NOT NULL DEFAULT ''Update table data
UPDATE eeemmppp SET salary = '9000' WHERE id ='120'Delete the old monster's record
DELETE FROM eemmpp
WHERE user_name = ' Old monster ';Various select usage
CREATE TABLE students(
`id` INT NOT NULL DEFAULT 1,
`name` VARCHAR(20) NOT NULL DEFAULT '',
`chinese` FLOAT NOT NULL DEFAULT '0.0',
`english` FLOAT NOT NULL DEFAULT '0.0',
`match` FLOAT NOT NULL DEFAULT '0.0'
);
INSERT INTO students(id,`name`,chinese,english,`match`) VALUES ('1',' Tang Bo ','100','100','100'),
INSERT INTO students(id,`name`,chinese,english,`match`) VALUES ('2',' Zhang Bo ','12','102','104');
SELECT * FROM students
SELECT * FROM students WHERE chinese =100
SELECT `name`,english FROM students WHERE english = 100
SELECT DISTINCT english FROM students
SELECT `name`,(chinese+english+`match`) FROM students
SELECT `name`,(chinese+english+`match`+10) FROM students
SELECT `name` AS ` full name `,(chinese+english+`match`+10) AS total FROM studentsHow many days are left
SELECT * FROM students
ORDER BY chinese
SELECT `name`,(chinese+english+`match`) AS total FROM students
ORDER BY total DESC
SELECT COUNT(*) FROM students WHERE chinese = 100
SELECT COUNT(*) FROM students WHERE `match` > 100
SELECT SUM(english) FROM students
SELECT SUM(english) AS english,SUM(chinese) AS chinese,SUM(`match`) AS `match` FROM students
SELECT AVG(`match`) FROM students
SELECT AVG(`match`+english+chinese) FROM students
SELECT MAX(`chinese`) FROM students
SELECT MIN(`chinese`) FROM students
# a key
SELECT AVG(`match`),MAX(english) FROM students GROUP BY chinese HAVING chinese > 20、
# How many days have I lived
SELECT DATEDIFF('2021-09-11','1996-08-18') FROM DUAL
SELECT DATEDIFF(NOW(),'1996-08-18') FROM DUAL
# Live to 80 How many days are left in the year old
SELECT DATEDIFF(DATE_ADD('1996-08-18',INTERVAL 80 YEAR),NOW()) FROM DUALCreate index and query index (UNIQUE Both index and ordinary index can be used ), Delete use DROP
SHOW TABLES
SELECT * FROM students
CREATE UNIQUE INDEX bobo ON students(`name`);
SHOW UNIQUE INDEX FROM studentsShow current database
# Display the current user and IP
SELECT USER() FROM DUAL
# Current database
SELECT DATABASE() FROM DUAL
#MD5 encryption
SELECT MD5(' Tang Bo 6768787') FROM DUALCapitalize to lowercase
SELECT CONCAT(LCASE(SUBSTRING(ename,1,1)), SUBSTRING(ename,2)) FROM empDisplay name without R Of Everyone's name
SELECT * FROM EMP
where ename not like "%R%"Display the first three characters of the employee's name
select LEFT(ename,3)
from empWrite in all capitals A Replace with lowercase a
select replace(ename,"A","a") from empWorking for more than ten years
select ename,hiredate
from emp
where DATE_ADD(hiredate,INTERVAL 10 YESR)< NOW()Create a new user format
CREATE USER 'bobo2' @'localhost' IDENTIFIED BY '123456'bobo2 Change your password set password=password('1234567')
root Changing Bobo's password can succeed
set password for 'bobo2' @ 'localhost'=password('1234567')root User give bobo2 Permission to view the table
GRANT SELECT,INSERT
ON db02.students
TO 'bobo2' @'localhost'to bobo2 Modify the permissions
GRANT UPDATE,INSERT
ON db02.students
TO 'bobo2' @'localhost'To view the user
SELECT * FROM mysql.user边栏推荐
- IE browser flash back, automatically open edge browser
- YOLOV3学习笔记
- Cesium entity(entities) 实体删除方法
- Loss function in pytorch multi classification
- Kubesphere - set up redis cluster
- Leetcode solution - 02 Add Two Numbers
- Click cesium to obtain three-dimensional coordinates (longitude, latitude and elevation)
- Oauth2.0 - explanation of simplified mode, password mode and client mode
- Maximum likelihood estimation, divergence, cross entropy
- 项目总结--2(Jsoup的基本使用)
猜你喜欢

Detailed explanation of contextclassloader

【系统设计】邻近服务

Zhiniu stock -- 03

.NET程序配置文件操作(ini,cfg,config)

Kubesphere - Multi tenant management

Bio, NiO, AIO details

JDBC connection database steps

. Net program configuration file operation (INI, CFG, config)

Kubesphere - build Nacos cluster

Analysis of Clickhouse mergetree principle
随机推荐
YOLOV1学习笔记
Simple handwritten ORM framework
项目总结--04
Leetcode problem solving summary, constantly updating!
致即将毕业大学生的一封信
Deep learning, thinking from one dimensional input to multi-dimensional feature input
Es remote cluster configuration and cross cluster search
Kubernetes notes (VII) kuberetes scheduling
1. 兩數之和
Jedis source code analysis (I): jedis introduction, jedis module source code analysis
从小数据量 MySQL 迁移数据到 TiDB
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
使用conda创建自己的深度学习环境
tabbar的设置
Core principles and source code analysis of disruptor
项目总结--2(Jsoup的基本使用)
Merge and migrate data from small data volume, sub database and sub table Mysql to tidb
Detailed explanation of contextclassloader
MySQL带二进制的库表导出导入
智牛股项目--04