Introduction to PL/sql:
Plsql is a process language that Oracle expands on the basis of SQL. Plsql provides typical high-level language features, including encapsulation, exception handling mechanisms, information hiding, object-oriented, etc., and brings the latest programming ideas to the database server and toolset. Compared with Java, C #, Plsql's advantage is that the SQL language can be written directly to the Plsql "block" or plsql process, function. There is no need to create a statement object to execute SQL as in Java; This makes Plsql a very powerful transactional language that uses SQL to process data and uses a control structure to handle business logic.
Plsql in Oracle database server (used in stored procedures, functions, database triggers, package packages) and Oracle Development toolset (used in triggers for development tools components); Form Developer,report Developer You can also use a shared library that contains procedures and functions written using Plsql to extend a file called a PLL. SQL data types can also be used in Plsql, combined with direct access by the SQL provider, which consolidates the Plsql and Oracle database dictionaries. Plsql eliminates the barriers between the convenience of accessing databases and the process language.
Advantages:
1. Support SQL,SQL is the standard language to access the database, through the SQL command, the user can manipulate the database data. PL/SQL supports all data manipulation commands, cursor control commands, transaction control commands, SQL functions, operators, and pseudo-columns. At the same time, PL/SQL is tightly integrated and PL + supports all SQL data types and null values.
2. support for object-oriented programming , PL/SQL supports object-oriented programming, types can be created in PL/SQL, types can be inherited, methods can be overloaded in subroutines, and so on.
3. better performance , SQL is a non-procedural language, only one single execution, and PL/SQL to the unified implementation of a/PL, but also can be compiled PL/SQL block for reuse, reduce the communication between the application and server time, So PL/SQL is efficient and fast.
4. portability , application languages written in PL/SQL, can be ported to Oracle servers on any operating platform, and can also be written in a portable library for use in different environments.
5. security , the application logic between the client and the server can be segmented through the stored procedure, which restricts access to the Oracle database, and the database can also authorize and revoke access rights for other users.
Basic syntax for PL/sql:
PL/SQL is a block-structured language. A PL/SQL contains one or more logic fast, the logical block can declare variables, write the program body, can also catch exceptions and exception handling. Each logic is quickly divided into three parts, and the syntax structure is as follows:
The syntactic structure of PL/SQL
[DECLARE
--declaration statements] Variable or constant declaration section. Optional.
BEGIN
--executable Statements Executive section. Begin,end Ends (add; No.). Must be written.
[EXCEPTION
--exception statements] Exception handling section. Optional. The role and mechanism of exceptions in Java are the same.
END;
Attention:
1.pl/sql is a programming language that has its own unique data types, variable declarations and assignments, and process control statements.
2. Not sensitive to case, but in order to standardize: The keyword all uppercase, the rest of the lower case.
3. Each statement ends with a semicolon.
PL/SQL Special symbol Description:
Introduction to PL/SQL and basic syntax