Preface to the pre-course supplementary knowledge
Number (P,s)
Number (P,s): Numeric type, p indicates the valid length of the number (1th bit from the left of the number is not 0
Start counting until the far right length. Value range 0~38 bit), s represents the precision of the number (that is, the number of digits to the right of the decimal point, the value range -84~127 bit);
VARCHAR2 (s)
VARCHAR2 (s): variable-length character type. s represents the length of the string. Value range 1~4000 bit;
Char (s)
Char (s): a fixed-length character type. s represents the length of the string, the value range 1~2000 bit.
Date
Date: the time type. Indicates the date of the year, without length and precision. Value range A.D. December 31, 4713 ~ A.D. December 31, 9999
1 The SAV command uses
1.1 Saving the contents of a file with the SAV command
[Email protected]>create table T as select * from User_tables;
Table created.
[Email protected]>select count (*) from T;
COUNT (*)
----------
11
[Email Protected]>sav/home/oracle/sel_t.sql
Created File/home/oracle/sel_t.sql
[Email protected]>!
[[email protected] ~]$ ls
Sel_t.sql
[email protected] ~]$ cat Sel_t.sql
Select COUNT (*) from T
/
[Email protected] ~]$
1.2 Covered content SAV filename Rep
[Email Protected]>l
1* SELECT * FROM T ORDER by 1
[Email Protected]>sav/home/oracle/sel_t.sql Rep
Wrote File/home/oracle/sel_t.sql
[Email protected]>!
[email protected] ~]$ cat Sel_t.sql
SELECT * FROM T ORDER by 1
/
[Email protected] ~]$
1.3 Additional content SAV filename App
[email protected] ~]$ cat Sel_t.sql
SELECT * FROM T ORDER by 1
/
[[Email protected] ~]$ exit
Exit
[Email protected]>select count (*) from T;
COUNT (*)
----------
11
[Email protected]>sav/home/oracle/sel_t.sql app
Appended file To/home/oracle/sel_t.sql
[Email protected]>!
[Email protected] ~]$
[email protected] ~]$ cat Sel_t.sql
SELECT * FROM T ORDER by 1
/
Select COUNT (*) from T
/
[Email protected] ~]$
2. Spool command use
Spool on indicates that the cache is opened. Otherwise, you can save only 1 commands that are running recently.
Spool filename indicates that the commands and results appearing in the cache are output to a file;
Spool off means that the cache is closed and the file is saved on its own initiative;
[Email protected] ~]$ Sqlplus/as SYSDBA
Sql*plus:release 10.2.0.1.0-production on Wed June 18 13:52:25 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-production
With the partitioning, OLAP and Data Mining options
[Email Protected]>spool/home/oracle/sel_emp.sql
[Email Protected]>conn Scott/tiger;
Connected.
[Email protected]>select empno,ename from EMP;
EMPNO ename
---------- ----------
7369 SMITH
7499 ALLEN
7521 WARD
7566 JONES
7654 MARTIN
7698 BLAKE
7782 CLARK
7788 SCOTT
7839 KING
7844 TURNER
7876 ADAMS
EMPNO ename
---------- ----------
7900 JAMES
7902 FORD
7934 MILLER
Rows selected.
[Email protected]>spool off;
[Email Protected]>exit
[email protected] ~]$ cat Sel_emp.sql
[Email Protected]>conn Scott/tiger;
Connected.
[Email protected]>select empno,ename from EMP;
EMPNO ename
---------- ----------
7369 SMITH
7499 ALLEN
7521 WARD
7566 JONES
7654 MARTIN
7698 BLAKE
7782 CLARK
7788 SCOTT
7839 KING
7844 TURNER
7876 ADAMS
EMPNO ename
---------- ----------
7900 JAMES
7902 FORD
7934 MILLER
Rows selected.
[Email protected]>spool off;
[Email protected] ~]$
SQL Series (Basic)-Preface pre-course supplementary knowledge