Some of the company's Oracle projects have recently been transferred to Ms_sql and have encountered translation problems in translating Oracle functions into Ms-sql procedure.
Luo lists these questions:
First, Oracle basic type
| Oracle |
Mssql |
| Varchar2 |
varchar |
| Number |
Int |
| Number (15,2) |
Decimal (15,2) |
Second, sequence.
The sequence in Oracle, I was going to use a self-increment to add some small means to deal with, and later in the colleague's reminders, only to know that ms-sql2012 's new features also contain sequences.
Attach a simple SQL statement
Create sequence dbo. Sequence_voucher
As int
Start with 1
Increment by 1
Build a sequence that starts at 1 and adds 1 each time
View sequence: SELECT * from Sys.sequences
Specific test details, attached Portal:
Http://www.cnblogs.com/CareySon/archive/2012/03/12/2391581.html
Http://www.cnblogs.com/QinQouShui/p/3740707.html
Third, for update.
Example: Select NVL (id,-1) to v_id from student where id = 3 for update;
This is a lock table related usage.
1 SELECT * from TTable1 for update locks all rows of table, can read only and cannot be written
2 Select * from TTable1 where Pkid = 1 for update locks only pkid=1 rows
3 SELECT * from Table1 a join Table2 B in a.pkid=b.pkid for update lock all records for two tables
4 SELECT * from Table1 a joins Table2 B on a.pkid=b.pkid where a.pkid = Ten for update locks two tables in a row that satisfies the criteria
5. Select * FROM Table1 a joins Table2 B on a.pkid=b.pkid where a.pkid = Ten for update of A.pkid locks only rows that meet the criteria in Table1
For update is to lock all tables for update of the table corresponding to the condition of the following table
SELECT * from emp where empno = 7369 for update; The record for employee number 7369 in the table is locked. Other users cannot operate on the record, only queries. SELECT * from emp where empno = 7369 for update of Sal; Does this statement mean that only 7369 of the data in the Sal field of this row in the table is locked, and other data can be updated by other users? The result of the student test is the same as two statements.
For update of does not work when multiple tables are locked, user 1 does the following (any field in Table1 can be made later):
SELECT * FROM table1 A, table2 b where a.filed1 = B.filed1
for update of A.FILED1;
User 2 can lock table2 when doing the following, because User 1 only locks on table1:
SELECT * FROM Table2 b
For update
Portal: http://blog.csdn.net/indieinside/article/details/13296695
Oracle functions turns into Ms-sql procedure