当前位置:网站首页>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
边栏推荐
- Kotlin基础学习 16
- Oracle 查看被锁的表和解锁
- 汇率的查询接口
- GSE104154_ scRNA-seq_ fibrotic MC_ bleomycin/normalized AM3
- C#联合halcon脱离halcon环境以及各种报错解决经历
- C#聯合halcon脫離halcon環境以及各種報錯解决經曆
- Competition and adventure burr
- [HCIA continuous update] working principle of OSPF Protocol
- Qt的网络连接方式
- Design details of SAP e-commerce cloud footernavigationcomponent
猜你喜欢
"Analysis of 43 cases of MATLAB neural network": Chapter 42 parallel operation and neural network - parallel neural network operation based on cpu/gpu
"Analysis of 43 cases of MATLAB neural network": Chapter 41 implementation of customized neural network -- personalized modeling and Simulation of neural network
微信小程序中 在xwml 中使用外部引入的 js进行判断计算
《MATLAB 神经网络43个案例分析》:第41章 定制神经网络的实现——神经网络的个性化建模与仿真
NLog使用
Getting started with MQ
QT environment generates dump to solve abnormal crash
Common means of modeling: aggregation
[HCIA continuous update] overview of dynamic routing protocol
Sentry experience and architecture, a fledgling monitoring product with a market value of $100million
随机推荐
What is hybrid web containers for SAP ui5
MySQL connection query and subquery
SAML2.0 notes (I)
Global and Chinese market of gynaecological health training manikin 2022-2028: Research Report on technology, participants, trends, market size and share
One of the future trends of SAP ui5: embrace typescript
C # joint Halcon's experience of breaking away from Halcon environment and various error reporting solutions
Yan Rong looks at how to formulate a multi cloud strategy in the era of hybrid cloud
Kotlin基础学习 14
leetcode-1380. Lucky number in matrix
Work hard all day long and be alert at sunset
aaaaaaaaaaaaa
Go执行shell命令
JDBC details
JS generate random numbers
PY3 link MySQL
Gradle notes
Verilog 状态机
焱融看 | 混合雲時代下,如何制定多雲策略
Grpc quick practice
js生成随机数