当前位置:网站首页>QT database learning notes (I) basic concepts of database
QT database learning notes (I) basic concepts of database
2022-06-11 02:02:00 【Penguins on the volcano】
List of articles
QT For other articles, please click here : QT Learning notes

One 、 Concept
● database DB(DataBase)
It's the warehouse where data is stored , Its characteristic is that the data is organized according to the data model , Is highly structured , It can be shared by multiple users and has certain security .
● Database management system DBMS(DataBase Management System)
It is a database management system software located between the user application and the operating system , Its main function is to organize 、 Storing and managing data , Efficiently access and maintain data , frequently-used DBMS Yes Oracle、Microsoft SQL Server and MySQL etc. .
● What is? SQL Language ?
Structured query language (Structured Query Language,SQL) Is a standard language for relational database operations ,
● SQL The composition of the three parts
1)、 Data definition language (Data Description Language,DDL), Data definition language DDL Used to create 、 Delete 、 Modify various objects in the database ----- surface 、 View 、 Indexes 、 A synonym for 、 Clustering, etc
Create database : Create database
Alter database : modify the database
Create table : Create new table
Alter table : change ( change ) Database table
Drop table : Delete table
Create index : Create index ( The search button )
Drop index : Delete index
2)、 Data manipulation language (Data Manipulation Language,DML), Used to manipulate various objects in the database , Retrieve and modify data
Select : Getting data from a database table
Update : Update the data in the database
Delete : Delete data from the database table
Insert into : Insert data into the database
3)、 Data control language (Data Control Language,DCL) For safety management , Determine which users can view or modify data in the database
① to grant authorization
GRANT: to grant authorization
② Roll back
ROLLBACK [WORK] TO [SAVEPOINT]: Go back to a certain point .
SQL>ROLLBACK; The rollback command returns the database state to the last committed state .
③ Submit
COMMIT [WORK]: Submit .
● Explicitly commit , use COMMIT The commit done directly by the command is an explicit commit .
SQL>COMMIT;
● Implicitly submit , use SQL The commit done indirectly by the command is an implicit commit .
ALTER,AUDIT,COMMENT,CONNECT,CREATE,DISCONNECT,DROP,EXIT,GRANT,NOAUDIT,QUIT,REVOKE,RENAME.
● Automatic submission , If the AUTOCOMMIT Set to ON, Then insert 、 modify 、 After the delete statement is executed , The system will automatically submit , This is auto submit .
SQL>SET AUTOCOMMIT ON;
● Database table
A database usually contains one or more tables . Each table has a name identifier , Table contains records with data ( That's ok ), as follows :
● QtSql Module hierarchy 
● Qt5 Database driven
Qt SQL The module uses database driver to communicate with different database interfaces . because Qt Of SQL The interface of the model is database independent , So all the database specific code is included in these drivers .Qt The database driver supported now is shown in the figure below .
Two 、 Data manipulation language DML( Add or delete check change )
1. increase (INSERT)
● INSERT grammar
grammar 1:
INSERT INTO target [IN externaldatabase] (fields_list)
{
DEFAULT VALUES|VALUES(DEFAULT|expression_list)}
grammar 2:
INSERT INTO target [IN externaldatabase] fields_list
{
SELECT…|EXECUTE…}
● example
insert into teacher values(”,’allen’,' Dalian No.1 Middle School ’,'1976-10-10′);
insert into student values(1,' Zhang San ',21)
2. Delete (DELETE)
● DELETE grammar
DELETE FROM table_names
[WHERE…]
● example
① from students Delete the name in the table as “ Luo Liang ” The record of :
DELETE FROM students WHERE name = ' Luo Liang '
② from students In the table to delete ID by “3” The record of :
delete from students where id = 3
3. check (SELECT )
● complete SELECT grammar
SELECT [DISTINCT] [ Alias .] Field name or expression [AS Column headings ] /* Specify the columns or rows to select and their qualifications */
FROM table_source /* FROM Clause , Specify a table or view */
[ WHERE search_condition ] /* WHERE Clause , Specify query criteria */
[ GROUP BY group_by_expression ] /* GROUP BY Clause , Specify grouping expression */
[ ORDER BY order_expression [ ASC | DESC ]] /* ORDER BY Clause , Specify sort expression and order */
● example
① Inquire about Student database . Inquire about students Name and total credits of each student in the table .
USE Student SELECT name,totalscore FROM students
② Query all records in the table . Inquire about students All the information of each student in the table , Most used
SELECT * FROM students
③ Conditions of the query . Inquire about students The total credits in the table are greater than or equal to 120 The situation of my classmates .
SELECT * FROM students WHERE totalscore >= 120
④ Conditions of the query & Get the Department name and total score . Inquire about students The total credits in the table are greater than or equal to 120 The situation of my classmates .
SELECT department,name,totalscore FROM students WHERE totalscore >= 120
⑤ Multiple criteria query . Inquire about students The system in the table is “ Computer ” And the total credits are greater than or equal to 120 The situation of my classmates .
SELECT * FROM students WHERE department=' Computer ' AND totalscore >= 120
⑥ Use LIKE Predicate for pattern matching . Inquire about students Last name in the table “ king ” And the situation of single name students .
SELECT * FROM students WHERE name LIKE ' king _'
4. Change (UPDATE)
● UPDATE grammar
UPDATE table_name
SET Field_1=expression_1[,Field_2=expression_2…]
[FROM table1_name|view1_name[,table2_name|view2_name…]]
[WHERE…]
among ,Field Is the field that needs to be updated ,expression Represents the new value expression of the field to be updated .
● example
① Increase the total score of computer students 10:
UPDATE students
SET totalscore = totalscore + 10
WHERE department = ' Computer '
② take ID by 2 The name of the student is changed to “ Xiao Ming ”:
update students
SET name = ' Xiao Ming '
WHERE id = 2
QT For other articles, please click here : QT Learning notes
Reference resources : QT/C++ Foundation and improvement series QT Intermediate series of video courses
边栏推荐
- 关于CS-3120舵机使用过程中感觉反应慢的问题
- Task01: be familiar with the basic process of news recommendation system
- Leetcode 698 partition to K equal sum subsets (DFS pruning)
- Leetcode 430 flat a multilevel double linked list (DFS linked list)
- Leetcode 1094 car pooling (Analog)
- 字节北京23k和拼多多上海28K,我该怎么选?
- 5月B站榜单丨飞瓜数据UP主成长排行榜(B站平台)发布
- 爱思唯尔---Elseviewer---预印本在线发表通知
- Wrong question (character array)
- Deep exploration of functions with indefinite parameters in C language
猜你喜欢
![[BSP video tutorial] BSP video tutorial issue 17: single chip microcomputer bootloader topic, startup, jump configuration and various usage of debugging and downloading (2022-06-10)](/img/69/1e2a71f123527b9aa8381cb9b86f7f.png)
[BSP video tutorial] BSP video tutorial issue 17: single chip microcomputer bootloader topic, startup, jump configuration and various usage of debugging and downloading (2022-06-10)

Clip paper details

Dinner a bang's Craft

Leetcode 430 flat a multilevel double linked list (DFS linked list)
![[music] playing city of the sky based on MATLAB [including Matlab source code 1874]](/img/cf/63b04080867e93ab2e00e2e21b37df.jpg)
[music] playing city of the sky based on MATLAB [including Matlab source code 1874]

CLIP论文详解

Fallible point--
![[music] playing](/img/cf/63b04080867e93ab2e00e2e21b37df.jpg)
[music] playing "over fire" based on MATLAB [including Matlab source code 1875]
![[leetcode] different binary search trees (recursion - recursion + memory search optimization - dynamic programming)](/img/ae/a6e7b8ebb098f631344024ffa80e76.jpg)
[leetcode] different binary search trees (recursion - recursion + memory search optimization - dynamic programming)

Understanding of pointers
随机推荐
[matlab] basic operation of MATLAB image processing
Matlab array other common operation notes
Start with interpreting the code automatically generated by BDC, and explain the trial version of the program components of sapgui
逻辑漏洞 / 业务漏洞
LeetCode 1609 Even Odd Tree (bfs)
Leetcode 2171 removing minimum number of magic beans (prefix and recommendation)
Dinner a bang's Craft
[traitement d'image] système multifonctionnel de traitement d'image basé sur l'interface graphique MATLAB [y compris le code source MATLAB 1876]
2021-02-03美赛前MATLAB的学习笔记(灰色预测、线性规划)
The argument type ‘int?‘ can‘t be assigned to the parameter type ‘num‘
Dialog AlertDialog 、SimpleDialog、showModalBottomSheet、showToast Flutter 自定义 Dialog
字节北京23k和拼多多上海28K,我该怎么选?
数据库概述
2021-2-14 gephi learning notes
Project sorting of Online Exercise System Based on gin and Gorm
---排列数字---
Database overview
[music] playing "over fire" based on MATLAB [including Matlab source code 1875]
Sequence table exercises
Initialize the one-dimensional array a correctly