当前位置:网站首页>First knowledge of database
First knowledge of database
2022-07-03 16:06:00 【t17246】
1 database (DataBase)
database : A warehouse for storing data
characteristic : You can think of it as an improvement on the file system . It solves the problem between different operating systems , Compatibility of data formats . in other words , As long as it is a data file of the same database , Even from Windows Moved to Linux On , It can also be handled normally .
2 Database classification
It can be divided into two categories: relational and non relational
Relational database : about java for , A class can correspond to a table , A class object can correspond to a row of data in the table , A member variable can correspond to a column in the table , Be able to map one by one , In the database, the .. besides It is also mainly reflected in its own relationship model , It reflects the relationship between tables
Non relational database : Is to store key value pairs , There is no association between each table , They're all independent . But it has the convenience of processing data in relational database , It can also process a large amount of data , What's hot is Redis、mongoDB.
3MySQL brief introduction
MySQL What is used SQL Language is the most commonly used standardized language for accessing database .MySQL The software adopts a dual licensing policy , It is divided into community version and commercial version , Because of its small size 、 Fast 、 Low total cost of ownership , Especially open source , In general, small and medium-sized sites are chosen for development MySQL As website database .
Database objects : surface , View , function , stored procedure , Index, etc. .
surface
It's where data is stored , There are records in it , Records are made up of fields . Each field has its own field name 、 field value 、 Field type ( data type ). Fields are the basic unit for storing data . similar Java Objects in the , For storing data .
View
We can understand it as a virtual table ( It doesn't really exist on physical disks ). The view is based on select The result set generated by the statement query . When one select When the statement is complex and the call frequency is high , We don't want to write the sentence again , At this time, you can put this select Statement is created as a view . Every time you use a view , You can use it as a watch .
function
It is usually the implementation of a function , Most of us use system functions (MYSQL Provided ), We can also customize functions . Its calling routine is through the use of select Function name ( Parameters 1, Parameters 2..); To call . It has only one return value .
stored procedure
It is also the realization of a function . What we call database programming ,SQL Statement programming , It mainly refers to customizing a stored procedure . Calling a stored procedure uses exec Stored procedure name Parameters 1 Wait to call . It can return multiple values , There can be no return value .
Indexes
We've been in contact with , It's like a book catalog , It is established to speed up our query .
5.2 ordinary sql The command operation
// Database view version number
select version();
// View all local databases
show databases;
// Write what you check
select 'xxx'
// Switch database
use test ;
// Look at all the tables
show tables;
// sign out Exit
5.3 User creation and Authorization
1) Create user : CREATE USER 'USERNAME' @ 'host' IDENTIFIED BY 'password' ;
Need to switch to mysql Under database operation user surface
username: user name , host: Specify which host can log in , This machine is available localhost,% General configuration of all remote hosts ;password: User login password ;
2) to grant authorization : GRANT ALL ON ”." TO username'@'%'
Format : grant jurisdiction on Database name . indicate .to user @ Log on to the host identified by " User password ";
jurisdiction :
Select Inquire about
Insert insert data
Update Update data
Delete Delete data
Drop Delete table
Create Create table
3) Cancel the authorization
revoke Follow grant The syntax is similar , Just put the keywords “to” Switch to “from” that will do
grant all on . to
Delete user , Will synchronize user and db Delete the corresponding data in all tables
drop user user name @'%’;
6 data type
When creating a table , Data type used , The purpose is to limit the type of data , Commonly used : floating-point , Character , Date time type, etc
Numerical type :
Time type
String type
7SQL The classification of
1)DCL Data control language , Represent keyword : grant,revoke
2) DDL Data definition language , Represent keyword : create,drop
a Database creation Delete : Creat, drop
b The creation and deletion of tables in the database
grammar : create table XXX(
Name type ,
listed type
);
3) DML Data operation language , Represent keyword : insert,delete, update
a It is mainly used to insert... Into the database , modify , Keywords involved in deleting data include : insert delete update
b Insert
inser into Table name ( Name 1, Name 2) values( value 1. value 2);
c Update
update indicate set Name 1 = value , Name 2= value where Name = value ;
D delete
delete from Table name where Name = value ;
4) DQL Data query language : Represent keyword :select
select Column qualification from Table limit where Row qualification
5) TCL Transaction control language : Represent keyword : commit,rollback
边栏推荐
- Please be prepared to lose your job at any time within 3 years?
- How to use AAB to APK and APK to AAB of Google play apps on the shelves
- Distributed task scheduling XXL job
- A Fei's expectation
- C language brush questions ~leetcode and simple questions of niuke.com
- 潘多拉 IOT 开发板学习(HAL 库)—— 实验5 外部中断实验(学习笔记)
- “用Android复刻Apple产品UI”(2)——丝滑的AppStore卡片转场动画
- [combinatorics] combinatorial identities (review of eight combinatorial identities | product of combinatorial identities 1 | proof | use scenario | general method for finding combinatorial numbers)
- App移动端测试【4】apk的操纵
- Pyinstaller is not an internal or external command, nor is it a runnable program or batch file
猜你喜欢
Q2 encryption market investment and financing report in 2022: gamefi becomes an investment keyword
WinDbg analysis dump file
The accept attribute of the El upload upload component restricts the file type (detailed explanation of the case)
"Remake Apple product UI with Android" (2) -- silky Appstore card transition animation
Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package
Uploads labs range (with source code analysis) (under update)
VS2017通过IP调试驱动(双机调试)
Principles of several common IO models
Microservice API gateway
【Proteus仿真】74HC595+74LS154驱动显示16X16点阵
随机推荐
工资3000,靠“视频剪辑”月入40000:会赚钱的人,从不靠拼命!
How idea starts run dashboard
MB10M-ASEMI整流桥MB10M
Microservice - fuse hystrix
Embedded development: seven reasons to avoid open source software
[系统安全] 四十三.Powershell恶意代码检测系列 (5)抽象语法树自动提取万字详解
Please be prepared to lose your job at any time within 3 years?
Brush questions -- sword finger offer
《微服务设计》读书笔记(上)
Uploads labs range (with source code analysis) (under update)
Microservice API gateway zuul
Creation and destruction of function stack frames
UnityShader——MaterialCapture材质捕捉效果 (翡翠斧头)
Detailed explanation of string function and string function with unlimited length
Persisting in output requires continuous learning
Large CSV split and merge
半监督学习
Microservice - Nacos registration center and configuration center
VC下Unicode和ANSI互转,CStringW和std::string互转
Unity function - unity offline document download and use