当前位置:网站首页>Account management of MySQL
Account management of MySQL
2022-07-02 03:28:00 【An Li Jiu Ge】
Catalog
Two 、 Three paradigms of database
3、 ... and 、 Account management
One 、SQL sketch
1.SQL Overview
Structure Query Language( Structured query language ) abbreviation SQL, It was approved by the National Bureau of standards (ANSI) American Standard for relational database language , Later by international standards organization (ISO) International standards adopted as relational database language . The database management system can be through SQL Management database ; Definition and operation data , Maintain data integrity and security .
2.SQL The advantages of
1、 Easy to learn , It has strong operability
2、 Most important database management systems support SQL
3、 Highly unprocessed ; use SQL When operating a database, most of the work is done by DBMS Done automatically
Two 、 Three paradigms of database
1、 First normal form (1NF) It means that each column of the database table is an inseparable basic data line ; in other words : The value of each column is atomic , It's indivisible .
2、 Second normal form (2NF) It's in the first paradigm (1NF) On the basis of , Satisfying the second paradigm (2NF) We must first satisfy the first paradigm (1NF). If the table is a single master key , Then columns other than the primary key must be completely dependent on the primary key ; If the table is a composite primary key , Then columns other than the primary key must be completely dependent on the primary key , You can't rely on just a part of the primary key .
3、 Third normal form (3NF) It is based on the second paradigm , That is, to meet the third paradigm, we must first meet the second paradigm . Third normal form (3NF) requirement : The non primary key column in the table must be directly related to the primary key, not indirectly ; in other words : Non primary key columns cannot depend on each other .
3、 ... and 、 Account management
Access to the company's database is divided , If one day you become a manager or .... So authorization or something can't be arranged .
# Create user ---- Zhang San
CREATE user zs;
# View user information
select host,user,authentication_string from user;
# Set the password
ALTER USER 'zs'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
# Give permission to the user
grant all on studentmanager.* to 'zs'@'%'
# Take back authority
revoke delete on studentmanager.* from 'zs'@'%'
# View all permissions
show grants for 'zs'@'%'
create user ls;
ALTER USER 'ls'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
grant select,delete on studentmanager.tb_class to 'ls'@'%'
CREATE DATABASE zhw
# Query database version
select version()
# Query the database
show databases;Four 、SQL Basic statement
Build table
CREATE TABLE book(
id INT,# Number
bName VARCHAR(20),# Book name
price DOUBLE,# Price
authorId INT,# Author No
publishDate DATETIME# Publication date )The modification of table
#① Change column names
ALTER TABLE book CHANGE COLUMN publishdate pubDate DATETIME;
#② Modify the type or constraint of the column
ALTER TABLE book MODIFY COLUMN pubdate TIMESTAMP;
#③ Add new column
ALTER TABLE author ADD COLUMN annual DOUBLE;
#④ Delete column
ALTER TABLE book_author DROP COLUMN annual;
#⑤ Modify the name of the table
ALTER TABLE author RENAME TO book_author;
DESC book;Table delete
DROP TABLE IF EXISTS book_author;
SHOW TABLES;Table replication
#1. Just copy the structure of the table
CREATE TABLE copy LIKE author;
#2. Copy the structure of the table + data
CREATE TABLE copy2
SELECT * FROM author;
# Copy only part of the data
CREATE TABLE copy3
SELECT id,au_name
FROM author
WHERE nation=' China ';
# Just copy some fields
CREATE TABLE copy4
SELECT id,au_name
FROM author
WHERE 0;5、 ... and 、 Case study


1、 Every purchase in January is full 20 Total consumption of yuan
select sum(order_amt) from t_user where user_id=(select distinct user_id from t_user where user_id not in (select user_id from t_user where order_amt < 20 or not MONTH(ORDER_TIME) = 1))

2、 People who only ordered spicy hot and hamburgers in January
边栏推荐
- Work hard all day long and be alert at sunset
- Spark Tuning
- Verilog 过程赋值 区别 详解
- [untitled] basic operation of raspberry pie (2)
- Global and Chinese markets for infant care equipment, 2022-2028: Research Report on technology, participants, trends, market size and share
- "Analysis of 43 cases of MATLAB neural network": Chapter 41 implementation of customized neural network -- personalized modeling and Simulation of neural network
- 微信小程序中 在xwml 中使用外部引入的 js进行判断计算
- JIT deep analysis
- [HCIA continuous update] overview of dynamic routing protocol
- ORA-01547、ORA-01194、ORA-01110
猜你喜欢

MSI announced that its motherboard products will cancel all paper accessories
![[mv-3d] - multi view 3D target detection network](/img/aa/741b36ead2dfaa5a165401b8d657b7.jpg)
[mv-3d] - multi view 3D target detection network

MySQL之账号管理

Form custom verification rules
![[HCIA continuous update] overview of dynamic routing protocol](/img/03/83c883afb63b7c63f6879b5513bac3.jpg)
[HCIA continuous update] overview of dynamic routing protocol

汇率的查询接口

"Analysis of 43 cases of MATLAB neural network": Chapter 41 implementation of customized neural network -- personalized modeling and Simulation of neural network

Verilog state machine

【DesignMode】原型模式(prototype pattern)

Retrofit's callback hell is really vulnerable in kotlin synergy mode
随机推荐
uniapp 使用canvas 生成海报并保存到本地
Oracle 查看被锁的表和解锁
Kotlin basic learning 17
[database]jdbc
Docker installs canal and MySQL for simple testing and implementation of redis and MySQL cache consistency
Kotlin 基础学习13
Verilog reg register, vector, integer, real, time register
In depth interpretation of pytest official documents (26) customized pytest assertion error information
Failed to upgrade schema, error: “file does not exist
One of the future trends of SAP ui5: embrace typescript
高性能 低功耗Cortex-A53核心板 | i.MX8M Mini
Intersection vengraph
JDBC details
Exchange rate query interface
Unity脚本的基础语法(8)-协同程序与销毁方法
Go execute shell command
【DesignMode】原型模式(prototype pattern)
aaaaaaaaaaaaa
Kotlin基础学习 14
Global and Chinese market of gynaecological health training manikin 2022-2028: Research Report on technology, participants, trends, market size and share