Oracle Data Processing

Source: Internet
Author: User

DML language             &: Address symbol (preparestament)             Batch processing: Insert- -------to insert the employees of Department 10th into a new table;                            It does not have to write the values statement; The list of value in the subquery should correspond to the column names in the Insert sub-clause;                      &NBS P   Delete is different from truncate: 1;delete is deleted, and truncate destroys the table first, then creates a new table;               / nbsp                          ,         &NB Sp               2: The main difference is two different languages;                &N Bsp                          ,         &NB Sp               3;delete will not free up space, while truncate can;            &NBS P &nbsP                          ,         &NB Sp                 4:delete Delete will be fragmented and truncate will not generate;                                   ,         &NB Sp                       5:delete can be flashed back and truncate not be able to flash back;    &NB Sp                     Set Feedback off command: Do not display execution language;      &NB Sp     Execute the SQL script command on the hard disk: such as: @c:\sql.sql; Test results: Delete operation Fast;            
DCL Language Oracle's things are automatically turned on, manually submitted (show: commit; implicit: normal exit, DDL statement) rollback (display: rollback; implicit: abnormal exit, power outage, downtime); SavePoint by saving point can be more Good control of things; Create a savepoint command: savepoint save name; Oracle-supported level of things: READ commited (default), Serializable,read only;
The DDL language object has 12 tables: permissions are required to create the table, and we can quickly build a table with subqueries, which can be modified by add,modfiy,drop,rename. Ora CLE Recycle Bin: Show RecycleBin view Recycle Bin, purge recyclebin empty Recycle Bin, not every user has Recycle Bin, the administrator does not have Recycle Bin, ordinary user will have Recycle Bin; How do I retrieve a table from my Recycle Bin? ---flash back courseTable constraints: Not null,unique,primary key,foreign key,check; Generally create tables and create constraints separate, easy to read; Examples of constraints:
CREATE TABLE Student
(
PID number constraint STUDENT_PK primary key,
sname varchar2 (constraint) student_name_notnull not NULL,
gender VARCHAR2 (2) Constraint Student_gender check (gender in (' Male ', ' female ')),
email varchar2 (constraint student_email_unique unique)
constraint student_email_notnull not NULL,
deptno number constraint STUDENT_FK references dept (deptno) on DELETE Cascade
)
View: A logically related set of data drawn from a table; Objective: to simplify the search;Not recommended: Modify the table through the view;

sequence: The main function of sequences is to provide a value to the table's primary key, which has two properties nextval,currval;its characteristic: it is the number group, exists in the memory;data discontinuity: Rollback, System exception-power outage, multiple tables using a sequence;
Index: Improve query speed;such as: Create INDEX Myindex on EMP (deptno,job);                        Synonyms: Aliases
Oracle's Plsql
The fastest language to operate Oracle is PLSQL, the type of the variable: the underlying type, the reference variable (%type), the logging variable (%rowtype), and its assignment in two ways: ": =" and into keyword; set Serveroutput on command: Open console printout; Accept num prompt ' Enter ' command: accepts input on keyboard, plsql if statement must end with if end;
Cursors: Cursorused to store multiple rows of data returned by a query, its properties:%isopen Open,%rowcount Records,%notfound not recorded;use cursor first open and last close;oracle support up to 300 cursors; show paremeters view parameter settings;Case: Use the cursor to query the employee's name and salary, and print; Pay the employee a raise, President 1000, manager 800, other 400; it also needs to submit things manually;cursors with parameters: Their definitions, with parameters when the cursor is opened, and other usages with the same usage without cursors;Case: Querying the employee name of a department
exception: System comes with exceptions, custom exceptions, exceptions in Java are up-processing, and Plsql cannot be thrown up,in Java, try: Catch.. Finally and Plsql only try: Catch its notation is exception when. Then ... Custom Exception in declare: Exception name exception; Use raise to run out of exception, the exception will help you to automatically close the cursor;

Example One: Statistics of the number of persons entering the year;example two: For employees to raise wages, from the minimum wage to raise no one up 10%, but the total wages can not exceed 50,000 yuan; Please calculate the number of wage increases and payroll after the increase in wages, and output wage increases and payroll;
===================================================== stored procedure (no return value), store function (with return value), trigger Java cannot call Plsql directly, but write stored procedure, store function, let           After using Java to invoke; Create a stored claim: create[or Replace] procedure procedure name (parameter list) as Plsql subroutine body, parameter type and input and output to be marked; do not commit things in stored functions, stored procedures; Method of calling the stored procedure: Exec Procedure name (), call in another plsql: Begin process Name (); end; these two methods;            Create storage function: create[or Replace] procedure procedure name (parameter list) return value type as Plsql subroutine body; output parameters for out, stored procedures, storage functions can return one or more parameters, the two are basically no difference;Example One: Querying all the information for all employees in a departmentneed Baotou and package body:when the returned result is a collection, you can use the cursor to implement;            


            
           




Oracle Data Processing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.