Get the App
SLTechnology News&Howtos  ›  Database  › 

Basic Properties and Operations of SQL Foundation (1)

Shulou Source: shulou.com Published: 2022-06-01 15:47:36 09月27日 Update

SQL language has the following characteristics:

1. The SQL language is case-insensitive.

2. SQL can be written on one or more lines

3. Keywords cannot be abbreviated or branched

4. generally, each clause should be written on a separate line.

5. Use indentation to improve the readability of statements

6. SQL statements in SQL Developer can be terminated with a semicolon (;). When multiple SQL statements are executed, the semicolon that must be terminated

7. In SQL * Plus, you must end each SQL statement with a semicolon (;)

SQL Developer:

● default title alignment: left alignment

● default title displays: uppercase

SQL*Plus:

Left alignment of columns of ● characters and date types

Right alignment of columns of ● numeric types

● default field display: uppercase

Arithmetic expressions in SQL

The operation method of SQL:

Use arithmetic operators to create expressions that contain numeric and date data

+ plus

-minus

* multiply

/ divide

Arithmetic priority:

1. Multiplication and division take precedence over addition and subtraction

2. The same precedence operator is executed from left to right

3. The operation in parentheses is executed first.

4. NULL is an invalid, unspecified, unknown, or unpredictable value. NULL is not 0, nor is it a space

If there is a null in the mathematical operation, the result will be empty, regardless of addition, subtraction, multiplication and division.

The tests are as follows:

The specific case statements are as follows:

1. It shows the information of salary increase of 300 per person, and it is arranged in ascending order.

Select last_name, salary, salary+300 from employees order by salary+300

2. How much is it for each person to add 100 to his annual salary

Select last_name,salary,12*salary+100 from employees

3. It means that each employee will add 100 yuan per month, and what is the final annual salary?

Select last_name,salary,12* (salary+100) from employees

Tags: Operation statement priority semicolon arithmetic branch uppercase annual salary date title type expression language operator basis addition subtraction multiplication and division one line multiplication and division information key Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Tech Info Huawei MySQL Microsoft