Analysis of Oracle and SQL Server

xiaoxiao2021-03-06  48

T-SQL is the language engine of SQL Server, and Oracle's language engine is PLSQL. Both inquiry languages ​​extends the ANSI SQL-92 standard to provide additional support. The applications you create are almost all of these supplementary features. This article describes the most commonly used, non-standard Oracle extensions, as well as how to transform these extensions for use in a SQL Server environment. When you select the data query by PLSQL, the From clause is required, which is the same as SQL Server. The SELECT statement must select a target for a target. There is a special table DUAL in the Oracle database. The DUAL table is an actually existing table in Oracle, and any user can read, which is often used in the SELECT without a target table. The DUAL table is created by Oracle along with the data dictionary, and all users can access the table with Name DUAL. There is only one column of Dummy in this table, which is defined as a varchar2 (1) type, with a row value X. Selecting data from the DUAL table is often used to calculate constant expressions through the SELECT statement. So only one line of data is only one line, so the constant only returns once. The Dual Query under Oracle is as follows: SQL Server Query below: SELECT 'X' from DUAL is below: SELECT 'X' The following is null related knowledge, uses Dual: SQL> SELECT 1 from dual where null = null; did not find the record SQL> SELECT 1 from dual where null = ''; no recorded SQL> SELECT 1 from dual where '' = ''; no recorded SQL> SELECT 1 from Dual Where Null IS Null; 1 --------- 1SQL> SELECT 1 from dual where nVL (null, 0) = nVL (null, 0); 1 --------- 1 Check the current connection user SQL> Select User from Dual; View the current date, time sql> select sysdate from dual; Connect Oracle with || symbol as a connecting manner, and SQL Server's connection is a plus sign: . Oracle Query as follows: SELECT 'NAME' || 'Last Name' from tablename The corresponding SQL Server query is shown below: SELECT 'NAME' 'LAST NAME' Digital Oracle Database There is a TRUNC function in the Oracle database, the function returns M The N bit of the number of digits; if M is omitted, N is 0. The value of M can be negative, indicating that the M-bit number on the left side of the decimal point is intercepted. You can use Round or Floor under SQL Server. The following is an Oracle query: SELECT TRUNC (15.79, 1) "truncate" from dual; SQL Server version of the same query: SELECT ROUND (15.79, 0) Rounded, Round (15.79, 0, 1) Truncated SELECT FLOOR (Round) 15.79, 0)), Floor (Round (15.79, 0, 1)) Digital Conversion Oracle's TO_CHAR function can convert N-bit Number data types to a VARCHAR2 data type while adopting optional digital formats. SQL Server returns character data after digital conversion via the STR function.

转载请注明原文地址:https://www.9cbs.com/read-80288.html

New Post(0)