当前位置:网站首页>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边栏推荐
- Detailed explanation of contextclassloader
- In depth analysis of kubernetes controller runtime
- Alibaba cloud OOS file upload
- conda和pip的区别
- Use abp Zero builds a third-party login module (I): Principles
- Phpstudy setting items can be accessed by other computers on the LAN
- .NET程序配置文件操作(ini,cfg,config)
- Kubernetes notes (II) pod usage notes
- 深入解析kubernetes controller-runtime
- Project summary --01 (addition, deletion, modification and query of interfaces; use of multithreading)
猜你喜欢

项目总结--2(Jsoup的基本使用)

Kubernetes notes (10) kubernetes Monitoring & debugging

【系统设计】邻近服务

Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface

Interesting research on mouse pointer interaction

Deep learning, thinking from one dimensional input to multi-dimensional feature input

輕松上手Fluentd,結合 Rainbond 插件市場,日志收集更快捷

Oauth2.0 - user defined mode authorization - SMS verification code login

Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster

Simple solution of small up main lottery in station B
随机推荐
PHP用ENV获取文件参数的时候拿到的是字符串
Bernoulli distribution, binomial distribution and Poisson distribution, and the relationship between maximum likelihood (incomplete)
Skywalking8.7 source code analysis (II): Custom agent, service loading, witness component version identification, transform workflow
Phpstudy setting items can be accessed by other computers on the LAN
Oauth2.0 - using JWT to replace token and JWT content enhancement
剖析虚幻渲染体系(16)- 图形驱动的秘密
Apifix installation
Some thoughts on machine learning
When PHP uses env to obtain file parameters, it gets strings
conda和pip的区别
Svn branch management
冒泡排序的简单理解
项目总结--04
Understand the first prediction stage of yolov1
Kubernetes cluster environment construction & Deployment dashboard
Disruptor learning notes: basic use, core concepts and principles
使用 Abp.Zero 搭建第三方登录模块(一):原理篇
Detailed explanation of contextclassloader
Kubernetes notes (IV) kubernetes network
Synthetic keyword and NBAC mechanism