当前位置:网站首页>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边栏推荐
- 1. 兩數之和
- What's the difference between using the Service Worker Cache API and regular browser cache?
- Disruptor learning notes: basic use, core concepts and principles
- Kubernetes notes (IV) kubernetes network
- 1. Somme des deux nombres
- Skywalking8.7 source code analysis (II): Custom agent, service loading, witness component version identification, transform workflow
- Project summary --01 (addition, deletion, modification and query of interfaces; use of multithreading)
- In depth analysis of kubernetes controller runtime
- Use abp Zero builds a third-party login module (I): Principles
- Code generator - single table query crud - generator
猜你喜欢

Pytorch dataloader implements minibatch (incomplete)

表达式的动态解析和计算,Flee用起来真香

Method of converting GPS coordinates to Baidu map coordinates

Project summary --01 (addition, deletion, modification and query of interfaces; use of multithreading)

SQL实现将多行记录合并成一行

Zhiniu stock project -- 05

Zhiniu stock project -- 04

SVN分支管理

23 design models

Simple solution of small up main lottery in station B
随机推荐
项目总结--2(Jsoup的基本使用)
Reinstalling the system displays "setup is applying system settings" stationary
Support vector machine for machine learning
YOLOV2学习与总结
Interesting research on mouse pointer interaction
Get a screenshot of a uiscrollview, including off screen parts
輕松上手Fluentd,結合 Rainbond 插件市場,日志收集更快捷
YOLOV3学习笔记
Printer related problem record
Leetcode solution - 02 Add Two Numbers
Apple submitted the new MAC model to the regulatory database before the spring conference
JMeter performance automation test
MySQL带二进制的库表导出导入
Kubernetes notes (IV) kubernetes network
Es remote cluster configuration and cross cluster search
Analysis of Clickhouse mergetree principle
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
Click cesium to obtain three-dimensional coordinates (longitude, latitude and elevation)
有意思的鼠標指針交互探究
88. 合并两个有序数组