Software testing|SQL common syntax, do you know it?

foreword

As a language, SQL, like other programming languages, needs to follow some specific norms and guidelines, which is what we often call syntax (Syntax).

Here are a few syntax rules for SQL:

  • All SQL syntax must start with keywords (also known as commands), such as SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW, etc.
  • All SQL statements must end with a semicolon;. SQL statements can span lines, and you can write SQL statements in one or more lines.
  • SQL is case-insensitive, which means that SELECT and select are the same in SQL statements, but keywords usually appear in uppercase.

Note: Table names are case-sensitive, you must use table names that already exist in the database.

Example SQL syntax:

SELECT column_name FROM table_name; 

Commonly used SQL commands

1、SELECT

The SELECT command is used to query (select) data from the database, and its usage is as follows:

SELECT column1, column2....columnN
FROM   table_name;

2、UPDATE

The UPDATE command is used to update data in the database, and its usage is as follows:

UPDATE table_name
SET column1 = value1, column2 = value2....columnN=valueN
[ WHERE  CONDITION ];

3、DELETE

The DELETE command is used to delete data from the database, and its usage is as follows:

DELETE FROM table_name
WHERE  {CONDITION};

4、CREATE TABLE 

The CREATE TABLE command is used to create a new data table, and its usage is as follows:

CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
.....
columnN datatype,
PRIMARY KEY( one or more columns )
);

5、ALTER TABLE

The ALTER TABLE command is used to modify data tables. ALTER TABLE can be used to modify the fields of the data table, for example:

ALTER TABLE table_name {ADD|DROP|MODIFY} column_name {data_ype};

 It can also be used to modify the name of the data table, for example:

ALTER TABLE table_name RENAME TO new_table_name;

6、DROP TABLE 

The DROP TABLE command is used to delete a data table, and its usage is as follows:

DROP TABLE table_name;

7、CREATE DATABASE

CREATE DATABASE is used to create a new database, its usage is as follows:

CREATE DATABASE database_name;

8、INSERT INTO

The INSERT INTO command inserts new data into the database, and its usage is as follows:

INSERT INTO table_name( column1, column2....columnN)
VALUES ( value1, value2....valueN);

9、CREATE INDEX 

The CREATE INDEX command is used to create an index, and its usage is as follows:

CREATE UNIQUE INDEX index_name
ON table_name ( column1, column2,...columnN);

10、DROP INDEX

The DROP INDEX command is used to delete an index, and its usage is as follows:

ALTER TABLE table_name
DROP INDEX index_name;

Summarize

This article mainly explains the common syntax of SQL, including various operations of adding, deleting, modifying and checking. We will introduce related operations of SQL database later.

Finally, I wish everyone can find the job they want, work happily, live happily, have a broad world, and make great achievements. I also sorted out a wave of previously released software testing resources [click the small card at the end of the article to get it for free], there is no routine to get it!

Basically covers all the core technical points of software testing: testing theory, Linux basics, MySQL basics, Web testing, interface testing, App testing, management tools, Selenium related, performance testing, computer networks, composition principles, data structures and algorithms, logic questions, human resources, technical brain maps, etc... The quality is very high ! ! ! More than enough for technical interviews!

The entire document has a total of 308 pages . It is definitely unrealistic to show you all of them. In order not to affect your reading experience, only part of the content is shown. I hope you will bear with me. I hope it can help you review before the interview and find a good job, and save everyone time searching for information on the Internet to learn!

 


 

Guess you like

Origin blog.csdn.net/HUA1211/article/details/131767427