Comparison between Oracle database and MSSQL

Source: Internet
Author: User
Oracle SQL MS
Assignment Select col1 into v_name from employee Select @ name = Name from employee
Statement Declare v_user varchar2; Declare @ user varchar (200 );
Create a table with an existing table Create Table newtable as select * From oldtable; Select * into newtable from oldtable
Select the first n rows

Select * from (select * from Table order by ID) A where rownum <= N;

Select Top N * from table
Automatically add ID

Create trigger on table
Before insert
For each row
Is
Begin
Select squence. nextval into v_newid from dual;
: New. ID: = v_newid;
End;

A sequence needs to be created

Set a column to automatically increase
Connection table update

Update Table1 a set a. col1 = (select col2 from Table2 B where a. col1 = B. col2 );

Update a set a. col1 = B. col2
From Table1 a join Table2 B
On a. Cola = B. COLB

Use cursor

Declare v_name varchar2 (20 );
Cursor mycursor is select name from employee;
Begin
Open mycursor;
Loop
Fetch mycursor into v_name;
-- Do somethings;
Exit when mycursor % notfound;
End loop;
Close mycursor;

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.