当前位置:网站首页>SQL learning
SQL learning
2022-07-28 15:01:00 【Jun moshang】
Learning goals :
Have a good command of SQL sentenceLearning content :
Tips : Here you can add what you want to learn
1、 SQL Language is basically used
2、 Database related knowledge
Learning notes
The first lesson understand SQL
One 、 database : A database is a collection of data stored in an organized way . The simplest way to understand it is to think of the database as a file cabinet .
Two 、1、 The concept of table : If the database is a file cabinet , That table is a document . Table is a kind of Structured files , Can be used to store a specific type of data .
2、 Features of the watch :
<1> The data stored in the table is the same type of data or list .
<2> Every table in the database has a name to identify itself . This name is unique , That is, no other table in the database has the same name .
Particular attention : Make the table unique , In fact, it is a combination of database name and table name , That is to say, the same table name can be used in different databases .
3、 ... and 、 Pattern (schema): Information about the layout and properties of databases and tables .
Four 、 Columns and data types Table consists of columns . Columns store information about a part of a table .
1、 Definition of columns : A column is a field of a table . All tables consist of one or more columns .
Each column has its own data type .
2、 Data type definition : What types of data are allowed . Each table column has its own data type , It limits the data stored in this column .
5、 ... and 、 That's ok
The data in the table is stored by row , Each record saved is in its own line .
Definition of line : A record in the table .
6、 ... and 、 Primary key
1、 Primary key definition : Every row in the table has a column ( Or several columns ) You can uniquely identify yourself .
2、 Primary key properties :
- Any two rows do not have the same primary key value
- Each row must have a primary key value ( The primary key value cannot be null NULL)
- The value in the primary key column is not allowed to be modified or updated
- Primary key values cannot be reused ( If you delete from the list , Its primary key cannot be paid to new lines in the future )
The second lesson Retrieving data
One 、SELECT sentence
1、 keyword : As SQL Reserved words for components . Keywords cannot be used as the names of tables or columns
Common keywords are :
<1>distinct
Display the product name without duplicate records , List of commodity prices and commodity categories
select distinct ware_name,price from t_ware;
<2> Use calculated Columns
Check all commodity price increases 20% After the price of
select ware_id,ware_name,price*1.2 from t_ware'
<3> Alias of column
a) Don't use as
select ware_id,ware_name,price*1.2 price_raise from t_ware;
b) Use as
select ware_id,ware_name,price*1.2 price_raise from t_ware;
2、 Retrieve a single column
The next operation will be in mysql Proceed under , This is a sample table
link :https://pan.baidu.com/s/15LFHKT-9jG4ImhtMSqVC9Q
Extraction code :qa2v
Input
SELECT prod_name
FROM Products;
This is from Products Search for a table named prode_name The column of . The column names of the required columns are written in SELECT After keyword ,FROM Keywords indicate which table to retrieve data from .
Here we need to pay attention to SQL Statement is case insensitive . But according to habit SQL Capitalize keywords , Lower case the column name and table name
3、 Retrieve multiple columns
To retrieve multiple columns from a table , Still use the same SELECT sentence . The only difference is that it has to be SELECT Multiple column names are given after the keyword , Column names must be separated by commas . Be careful : The last column name cannot be added with a comma .
4、 Retrieve all columns
In addition to specifying the required columns ( As mentioned above , One or more columns ),SELECT Statement can also retrieve all columns without having to list them one by one . Use an asterisk in the position of the actual column name (*) Wildcards can do this . If given a wildcard (*), Then all columns in the table . Look at code
SELECT *
FROM Products;
5、 Retrieve different values
Now I just want to search Products Suppliers of all products in the table ID.
SELECT vend_id
FROM Products;
6、 Restriction result
SELECT Statement returns all matching rows in the specified table , Probably every line . If you want to return a row or a certain number of rows , Need to use limit.
for example , Now I want to limit the return of five lines
SELECT prod_name
FROM Products
LIMIT 5;
边栏推荐
- [Tanabata] Tanabata lonely little frog research edition? The final chapter of Tanabata Festival!
- Core Data 是如何在 SQLite 中保存数据的
- 9、 C array explanation
- 基础架构之日志管理平台及钉钉&邮件告警通知
- 使用Weka与Excel进行简单的数据分析
- Matlab load usage
- 4、 C language operators
- First class exercise
- 为自定义属性包装类型添加类 @Published 的能力
- Idea2020.1.4 packages package collapse
猜你喜欢

Chapter II linear table

Brief introduction and use of mqtt entry level

linux安装redis

Chapter 3 stack, queue and array

Google lab usage notes

MITK creates plug-ins and generates plug-ins

21、 TF coordinate transformation (I): coordinate MSG message

Simple data analysis using Weka and excel

PS modify the length and width pixels and file size of photos

Redis-配置文件讲解
随机推荐
linux安装redis
How to perform batch operations in core data
Keras reported an error using tensorboard: cannot stop profiling
Redis-Redis在Jedis中的使用
[complete installation package & tutorial] sqlserver basic installation_ Sqlserver completely uninstalled_ Sqlserver custom installation_ Getting started with sqlserver_ SQLSERVER database
Namespace conflict problem
The 35 required questions in MySQL interview are illustrated, which is too easy to understand
SwiftUI 布局 —— 尺寸( 上 )
Brief introduction and use of mqtt entry level
Pytorch GPU installation
Product Manager
Machine learning related concepts
9、 C array explanation
&0xffffffff(0x08)
Shell command
企鹅一面:为什么不建议使用SELECT * ?
C language related programming exercises
Redis-配置文件讲解
Interviewer: what are the usage scenarios of ThreadLocal? How to avoid memory leakage?
Store and guarantee rancher data based on Minio objects