当前位置:网站首页>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
边栏推荐
- This article describes the step-by-step process of starting the NFT platform project
- Calculation of page table size of level 2, level 3 and level 4 in protection mode (4k=4*2^10)
- West digital decided to raise the price of flash memory products immediately after the factory was polluted by materials
- 流线线使用阻塞还是非阻塞
- Kotlin基础学习 17
- What do you know about stock selling skills and principles
- Unity脚本的基础语法(6)-特定文件夹
- Named block Verilog
- [database]jdbc
- 一天上手Aurora 8B/10B IP核(5)----从Framing接口的官方例程学起
猜你喜欢

Exchange rate query interface

Large screen visualization from bronze to the advanced king, you only need a "component reuse"!

Verilog 状态机

SAML2.0 notes (I)

Download and use of the super perfect screenshot tool snipaste
On redis (II) -- cluster version

JIT deep analysis

Detailed explanation of the difference between Verilog process assignment

Common means of modeling: aggregation

"Analysis of 43 cases of MATLAB neural network": Chapter 42 parallel operation and neural network - parallel neural network operation based on cpu/gpu
随机推荐
Design details of SAP e-commerce cloud footernavigationcomponent
Xlwings drawing
Gradle 笔记
Eight steps of agile development process
微信小程序中 在xwml 中使用外部引入的 js进行判断计算
uniapp 使用canvas 生成海报并保存到本地
Verilog 过程连续赋值
《MATLAB 神經網絡43個案例分析》:第42章 並行運算與神經網絡——基於CPU/GPU的並行神經網絡運算
QT environment generates dump to solve abnormal crash
C shallow copy and deep copy
What kind of interview is more effective?
Kotlin basic learning 14
Kotlin basic learning 16
数据库文件逻辑结构形式指的是什么
Common means of modeling: aggregation
Verilog avoid latch
Oracle的md5
"Analysis of 43 cases of MATLAB neural network": Chapter 41 implementation of customized neural network -- personalized modeling and Simulation of neural network
Aaaaaaaaaaaa
SAML2.0 notes (I)