当前位置:网站首页>Mysql database: introduction to database 𞓜 addition, deletion, modification and query
Mysql database: introduction to database 𞓜 addition, deletion, modification and query
2022-06-12 00:21:00 【Mountains and rivers cool in autumn】
database (database) It's for organizing , Warehouse for storing and managing data
Copy code database
Traditional database ( Also known as : Relational database or SQL database ) MySQL,Oracle,SQL Server New database ( Also known as : Non relational database or NoSQL database ) MongoDB
The data organization structure of traditional database
- database (database)
- In development , Usually each project corresponds to a separate database
- Data sheet (table)
- Different data , Stored in different tables
- For example, the user data is in users surface , Book data in books In the table
- data row (row)
- The rows in the table , Represents each specific piece of data
- Field (field)
- What information is stored in each table , Determined by the field
- Such as users Table design id,username,password These three fields
- Fields are similar to Excel The column of ,
- Each field has a corresponding data type
Create database
Don't use Chinese , Space with '_' Instead of
Copy code Create data table
- DataType data type
- int Integers
- varchar(length) character string
- tinyint(int) Boolean value
- Special identification of the field :
- PK(Primary Key) Primary key , Unique identification
- NN(Not Null) Value cannot be empty
- UQ(Unique) It's worth it
- AI(Auto Increment) The value increases automatically ( Usually to id Set up auto grow )
- Default/Expression The default value is ( When not assigned , Automatically set to default )
hypothesis id Is an automatically increasing and unique value , If the row data is deleted , The new data will not be used again id value
SQL: Structured query language
SQL Is a database programming language
SQL Code written in language , namely SQL sentence
Can only be used in relational databases (MySQL,Oracle,SQL Server)
Copy code grammar
SQL Keywords in statements are case insensitive , therefore SELECT,FROM Equivalent to select,from
Copy code - Select Statement is used to query data from a table , The results of the execution are stored in a result table ( Called result set ). The syntax is as follows
-- notes
-- from from designated 【 In the table 】, Query out 【 all 】 The data of ,* Represents all columns
SELECT * FROM The name of the table
-- from FROM designated 【 In the table 】, Query the specified Column name ( Field ) The data of
SELECT Column name FROM The name of the table
-- Between multiple columns ',' separate
SELECT username,password FROM users
Copy code - Insert into Statement is used to insert a new data row into a data table
-- Be careful : Columns and values should correspond to each other , Between multiple columns and multiple values , Use English commas to separate
INSERT INTO table_name ( Column 1, Column 2,...) VALUES ( value 1, value 2,...)
Copy code - Update Statement is used to modify the data in the table
-- use UPDATE Specify which table data to update
-- use SET Specify the new value corresponding to the column
-- use WHERE Specify the conditions for updating
-- UPDATE The name of the table SET Column name = The new value WHERE Column name = Certain value
UPDATE users SET password = 'zs8888' WHERE id = 7
-- Update several columns in a row
UPDATE users SET password = '123456',username = 'zs' WHERE ID = 2
Copy code Delete Statement to delete rows in a table
Be careful : Use delete If you forget to add where The condition will delete the data of the whole table Copy code
-- From the specified table , according to where The conditions offered , Delete the corresponding data row
DELETE FROM TABLE_NAME WHERE COL_NAME = VALUE
Copy code where Clause is used to qualify the selection criteria
stay select,update,delete In the sentence , Can be used where Clause to limit the selection criteria Copy codeOperator
=be equal to<>It's not equal to ( In some versions ,<>It can be written. '!=')>Greater than<Less than>=Greater than or equal to<=Less than or equal toBETWEENIn a certain rangeLIKESearch for a pattern
and/or Statements in where Combining two or more conditions in a clause
SELECT * FROM users WHERE uername<>'zs' AND id<3
SELECT * FROM users WHERE uername<>'zs' OR id<3
Copy code 边栏推荐
- m-way search trees
- Pycharm file name taboo
- Class. Getresource() and class Getresourceasstream() method
- [node] common methods of path module
- App startup process: from clicking the application icon to the activity startup process
- Seven trends in test automation that need attention
- 2022 618 notebook shopping guide
- How to package and send compressed files for mobile WPS
- [signals and systems] (XXI) Laplace transform and complex frequency domain analysis -- Laplace transform and its properties
- How to uninstall pscs6 in win10 system
猜你喜欢

Point cloud library PCL from introduction to mastery learning records Chapter 8

Test case design method

Experiment 7 class construction and static member function

Redis master-slave replication, sentinel mode and cluster

App startup process: from clicking the application icon to the activity startup process

win7 fps优化的方法

Teach you to play with SSM framework

IP addressing overview

oracle使用Navicat工具导入导出数据
![[signals and systems] (XXII) Laplace transform and complex frequency domain analysis - s-domain analysis](/img/35/a23646ac8501ac646cd44eeecd5b79.jpg)
[signals and systems] (XXII) Laplace transform and complex frequency domain analysis - s-domain analysis
随机推荐
chisel环境搭建(win10 + vscode)
APP项目怎么测?如何搭建测试体系
SAP SD 创建/修改价格表
Environment construction 2
多年测试菜鸟对黑盒测试的理解
【juc学习之路第6天】并发计算器与线程随机因子
Experiment 6 constructor + copy construction
Read 5g RF terminal industry
926. Flip String to Monotone Increasing
汛期化工和危险品企业如何加强防控重大安全风险
Design a MySQL table for message queue to store message data
2022 618笔记本选购指北
Openmmlab:ai CV framework
环境搭建2
DPT-FSNET: DUAL-PATH TRANSFORMER BASED FULL-BAND AND SUB-BAND FUSION NETWORK FOR SPEECH ENHANCEMENT
Dry goods | what do testers need to do for a complete performance test?
Do you want to take the postgraduate entrance examination? Will you be able to find a good job after graduate school?
Divide the array into three equal parts [problem analysis]
repeat_ L2-009 red envelope grabbing_ sort
时间选择器样式错乱 中间文字被遮挡