Oracle Literacy Study Notes

Introduction to SQL Language Classification:

DQL: data query language, select

DML: data manipulation language, insert update delete merge

DDL: data definition language, create alter drop truncate (truncated table structure and table data association, is a low-frequency operation)

DCL: Data Control Language, grant revoke

Oracle commands are case insensitive

In the command description, * means all, | means or, [] means optional, DISTINCT means deduplication

SQL statements can be wrapped and end with a semicolon

Keywords cannot be folded or abbreviated

Clauses are usually wrapped to improve readability

In sql*plus, uppercase is displayed by default, numbers are right-aligned, and characters are left-aligned

select command

select { * |[DISTINCT] column |expression [alias] ,...}from table ;

How to adjust the command display form:

Adjust display column width: column columnname format a30

View the definition of the table: desc (abbreviation of describe) table name

Data type description:

number(p,s) p means the effective length, s means the precision, the default is p:0-38, s: -84-127

Varchar2 (n) is a variable length type, n means 0-4000

char (n) represents a fixed-length type. The difference between variable-length and fixed-length types is that the underlying storage occupies different spaces. The fixed-length type will fill in spaces, and storage takes more space, but the fixed-length type is faster when retrieving, because the retrieval There is no need to truncate and calculate the position when.

date date type, the type has no length, and the value range is bc 4712,12,31-AD 9999.12.31

timestamp(n) represents the timestamp, accurate to milliseconds, and n represents the precision

Notice:

When selecting, keywords cannot be used as aliases. When there are spaces in the middle of the alias and keywords, they must be enclosed in double quotes to identify them.

The calculated intermediate data will be temporarily stored in memory. In the order by clause, it is possible to generate multiple copies of the results in memory

The null value is greater than any value, and when the null value is calculated, the value is empty

The precedence in the conditional clause is AND first, OR in the middle, and NOT last.

Guess you like

Origin blog.csdn.net/hezhou876887962/article/details/129638353