Knowledge test sites summary
IZ0-051
with check option
In view created by the with check option, when do dml must meet the conditions where we can either insert or update or delete. Can not be ignored, but also to meet the constraint original data table.
create table A as SELECT * FROM B
A table can only receive not null B table, the other constraint can not be created
months_beetween()
months_between (to_date ( '2019-05-31', 'YYYY-MM-DD'), to_date ( '2019-05-01', 'YYYY-MM-DD')) large date after the date of first small> 0 , whereas <0.
intersect
The intersection of two tables when not ignore null values, if a table has a blank record, b table is also available records do intersect the intersection of the time will be displayed. Column names can not be the same, but the type and number must be the same.
Column Name Definition ""
Must "" contents will be displayed intact, rather than double quotation marks "in the definition of a column name" column names are automatically capitalized.
Examples: SELECT MONTH ms, AREA "Name" FROM mxq; ms column names are automatically capitalized, "Name" will be displayed as Name
Escape q '[Camera's category is Photo]'
. Escaped the original in the parentheses where square brackets ' []' can be changed to any one of the special symbols such as, but must appear in pairs , '\ \', '< >', '| |'.
distinct
Only appears at the beginning of the sql statement, and can only occur once.
NULL operational rule
Any numerical value arithmetic null = null.
INTERVAL
A grammar
INTERVAL '123-1' YEAR (N) TO MONTH; N 2 by default, as the accuracy of 0-9;
SELECT INTERVAL '123-1' YEAR(3) TO MONTH FROM DUAL ;
Example 1
SELECT INTERVAL '123' YEAR(3) FROM DUAL ;
If the error will be less than 3, the result is; + 123-00
Example 2
SELECT INTERVAL '123' MONTH FROM DUAL; result: 2 + 10-03 default so 10 years
SELECT INTERVAL '123' MONTH (3) FROM DUAL; result: 010-03 accuracy is + 3 010 is so
From the results of Examples 2 can be seen two precision and accuracy of the latter month year later are represented in the accuracy.
Syntax two
The INTERVAL '{Integer | Integer time_expr | time_expr}'
{{DAY | HOUR | MINUTE} [(leading_precision)]
| SECOND, [(leading_precision [, fractional_seconds_precision])]}
[the TO {DAY | HOUR | MINUTE | SECOND, [(fractional_seconds_precision) ]}]
{} is required, [] is the time to fill can be filled, | is or.
An example of a
select interval '5 23: 45: 30.457' day to second (2) from dual; results +05 23: 45: 30.46, leading_precision defaults to 2
select interval '5 23: 45: 30.457' day (3) to second (2) from dual; results +005 23: 45: 30.46, leading_precision 3
Examples of the dicarboxylic
select interval '5 23: 45: 30.457' day (3) to minute from dual; given interval of the invalid, "523: 45: 30.457" format not to minute
select interval '5 23:45' day (3) to minute from dual; the result is +005 23: 45: 00, DAY | HOUR | MINUTE behind unacceptable precision, careful look behind only the second grammatical accuracy fractional_seconds_precision;
to sum up
Behind 1.interval format should comply to the latter format, such as '523: 45: 30.457' has accurate to the second, not to minute.
2.DAY | HOUR | precision is behind MINUTE day precision, TO DAY | HOUR | MINUTE | SECOND behind only the SECOND can pick accuracy.
Clob blob long data type
clob largest 4g varchar2 (4000) on the use of more than four thousand clob
4g used to store binary blob largest object classes such as pictures, music and so on.
There are long and blob clob type can not group by and order by statements directly.
Data type number, char, varchar2
number and length of char char can not write the default is 1, number not write the length of time you can store decimal places.
varchar2 length must be written, otherwise it will error
Create a table name rules
You can not use the reserved word table name can not start with a number, can not have *.
Table Name 1-30 characters, with up to 1000.
Constraint constraint
It can be both a primary and foreign keys
check SYSDATE not be used directly. can to_date ( '2014-01-12', 'YYYY-MM-DD') of this type of date.
.Nextval sequence and can not be directly used in the sequence .currval constraint.
Column-level constraints and table-level constraints
1. Directly behind the column is defined as a column-level constraint constraint,
2. After defining all the columns in the definition of constraints for the table level constraints
default and not null can only be column-level constraint
Mixing primary key or unique constraints can only be defined in the table level
CREATE TABLE WAREHOUSE (
WAREHOUSE_ID NUMBER(4),
ROOMNO NUMBER(10) CONSTRAINT R_ID CHECK(ROOMNO BETWEEN 101 AND 200), -------列级别
LOCATION VARCHAR2(25),
PROD_ID NUMBER(3),
CONSTRAINT WR_PR_PK PRIMARY KEY (WAREHOUSE_ID,PROD_ID),-----表级别
CONSTRAINT PROD_FK FOREIGN KEY (PROD_ID) REFERENCES PRODUCTS(PROD_ID)----表级别);
Multitable insert
INSERT ALL
INTO Sales_info VALUES (employee_id,week_id,sales_MON)
INTO Sales_info VALUES (employee_id,week_id,sales_TUE)
INTO Sales_info VALUES (employee_id,week_id,sales_WED)
INTO Sales_info VALUES (employee_id,week_id,sales_THUR)
INTO Sales_info VALUES (employee_id,week_id, sales_FRI)
SELECT EMPLOYEE_ID, week_id, sales_MON, sales_TUE,
sales_WED, sales_THUR,sales_FRI
FROM Sales_source_data;
INSERT ALL
WHEN SAL>10000 THEN
INTO sal_history VALUES(EMPID,HIREDATE,SAL)
WHEN MGR>200 THEN
INTO mgr_history VALUES(EMPID,MGR,SYSDATE)
SELECT employee_id EMPID, hire_date HIREDATE, salary SAL, manager_id MGR
FROM employees WHERE employee_id > 200;
NLS_DATE_FORMAT;
nvl2 function
FROM XZHDX
WHERE END_DATE - ST_DATE > 30
GROUP BY ZHENYING;
the SELECT the SUM (Shangjin), ZHENYING, MIN - (END_DATE ST_DATE)
the FROM XZHDX
the GROUP BY ZHENYING
the HAVING MIN (END_DATE - ST_DATE)> 30;
first packet is then calculated conditions having