In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The Foundation of MySQL Database (3)-- SQL language 1, SQL language introduction 1, SQL language introduction
SQL is a structured query language (Structured Query Language), a standard computer language for accessing and processing databases.
The functions of SQL language are as follows:
A, SQL executes queries to the database
B and SQL can retrieve data from the database.
C, SQL can insert new records in the database.
D, SQL can update the data in the database
E, SQL can delete records from the database
F, SQL can create a new database
G, SQL can create new tables in the database
H, SQL can create stored procedures in the database
I, SQL can create views in the database
J, SQL can set permissions for tables, stored procedures, and views
SQL is a standard computer language of ANSI, which is used to access and operate database systems. The SQL statement is used to retrieve and update data in the database. SQL works with database programs such as MS Access, DB2, Informix, MS SQL Server, Oracle, MySQL, Sybase, and other database systems.
Each database has its own version of the ANSI language, but in order to be compatible with the ANSI standard, SQL must support some major keywords (such as SELECT, UPDATE, DELETE, INSERT, WHERE, etc.) in a similar way.
In addition to the SQL standard, most SQL database programs have their own private extensions.
2. SQL language classification
SQL language is divided into data definition language, data control language, data operation language and data query language.
II. SQL language Foundation 1. Data definition language (DDL)
DDL:Data Definition Language
Used to define and manage data objects, including databases, data tables, functions, views, indexes, triggers, and so on. For example: CREATE, DROP, ALTER and so on.
Create table student
(
Sid INT
Sname varchar (20)
);
Alter table student add age int default 20
Drop table student
Drop database student
2. Data control language DCL)
DCL:Data Control Language
The language used to manage a database, including permissions to authorize user access, deny user access, and revoke granted permissions. For example: GRANT, DENY, REVOKE, COMMIT, ROLLBACK and so on.
Create a user
Create user 'wang'@'localhost' identified by' a1century'
Permission setting
Grant select on db.student to 'wang'@'localhost'
Revoke the authority
Revoke select on db.student from 'wang'@'localhost'
3. Data manipulation language (DML)
DML:Data Manipulation Language
Used to manipulate the data contained in database objects, add, delete, and modify. For example: INSERT, DELETE, UPDATE statements.
4. Data query language (DQL)
DQL:Data Query Language
It is used to query the data contained in database objects, and can carry out various database queries with different complexity, such as single table query, join query, nested query, set query and so on, and return the data to the client for display. For example: SELECT statement.
Constants and variables 1. Constants
A, character constant
String constants use single or double quotation marks, and numeric constants do not need quotation marks.
If the string constant requires line breaks, single quotation marks, double quotation marks%\
You need to add the escape character\ before it.
\ nWrap
\'a single quotation mark
\ "A double quote
\ an\ is considered as an escape character if there is no escape character.
If there is no escape character, it is considered to be a wildcard.
_ one is considered a wildcard if there is no transfer character.
Select 'hanli\' gang001'
Select 'han\ nligang001'
Select 'han\ nligang001'
Select "han\" ligang001 "
Select "Han Ligang 001"
B, numerical constant
Numerical constants do not need to add quotation marks
Select 100,100,200
C, Boolean constant
Boolean constant values true and false
Use 1s and zeros in SQL for
Select true,false
In expression
Select 100 > 200
Select 100), less than (=), less than or equal to (
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Select'This + (replace (convert (varchar (23), getdate (), 121),'-','),','),':','
© 2024 shulou.com SLNews company. All rights reserved.