SQL Server T-SQL and Oracle PL/SQL

Source: Internet
Author: User
T-SQL is an enhanced SQL language provided by SQLServer based on the SQL language. The T-SQL provides all the features of ANSISQL and adds more features such as extended functions, system pre-storage, and program design structures. The following describes

3. the T-SQL of SQL Server
T-SQL is an enhanced SQL language provided by SQL Server based on SQL language. The T-SQL provides all the features of ansi SQL and adds more features such as extended functions, system pre-storage, and program design structures. The following describes the enhancement features of several common T-SQL.
(1) T-SQL provides richer data types
The T-SQL provides multiple additional data types that can save up to 2 GB of data in one attribute of the database. In addition, the XML data type is provided for storing XML data.
(2) error handling mechanism
The T-SQL provides methods like try... catch statements in PHP to catch exceptions when SQL code is running.
The format is as follows.
BEGIN TRY
-- SQL code
END TRY
Begin catch TRAN_ABORT
-- Handle errors
END CATCH

4. Oracle PL/SQL
PL/SQL is an SQL extension provided by Oracle, similar to T-SQL. PL/SQL uses block syntax to complete a function. The block syntax format of PL/SQL is as follows.
[DECLARE]
--- Definition
BEGIN
--- Execution part
[EXCEPTION]
--- Exception handling
END
Each statement in PL/SQL ends with a semicolon. one or more SQL statements can be embedded.
Oracle provides four types of PL/SQL programs.
(1) function: the function can accept several parameters and return the processed variables. the syntax format is as follows.
FUNCTION name [{parameter1 [, parameter2,...])] RETURN date_type IS
--- Definition
BEGIN
--- Execution part
[EXCEPTION
--- Exception handling
END [name]
(2) process: similar to a function, the difference is that there is no return value. The syntax format is as follows.
PROCEDURE name [{parameter1 [, parameter2,...])] IS
--- Definition
BEGIN
--- Execution part
[EXCEPTION
--- Exception handling
END [name]
(3) package: a collection of various related objects, including multiple functions and processes.
(4) trigger: used to receive operations from the database and trigger a PL/SQL block.

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.