Access、SQLServer、Oracle常见SQL语句应用区别
Access、SQLServer、Oracle 常见 SQL 语句 应用 区别 关劲松 PMP 如果要兼容Access、SQL Server、Oracle三个数据库版本;我们在编写SQL 语句 的过程中,尽量使用一些通用的 语句 ,但还是有些方面有些 区别 避免不了,现简单总结一下。 以下A代表Access,S代
Access、SQLServer、Oracle常见SQL语句应用区别
关劲松 PMP
如果要兼容Access、SQL Server、Oracle三个数据库版本;我们在编写SQL语句的过程中,尽量使用一些通用的语句,但还是有些方面有些区别避免不了,现简单总结一下。
以下A代表Access,S代表SQL Server,O代表Oracle
1、取当前系统时间
A:Select Now()
S:Select Getdate()
O:Select Sysdate From Dual
2、连接字符串
A:&
S:+
O:||
3、字符串函数(截取字符串、大写、小写、查找字符串位置)
A:Mid、UCase、LCase、InStr
S:SubString、Upper、Lower、CharIndex
O:SubStr、Upper、Lower、InStr
4、判断取值语句
A:IIF
S:Case When Then
O:Decode
5、时间字段
A:要用#号分隔,或者转换为日期
SELECT * FROM Books WHERE RegDate = #2007-5-1# 或
SELECT * FROM Books WHERE RegDate = CDate(’2007-5-1′)
S:可以直接用''
SELECT * FROM Books WHERE RegDate = ‘2007-5-1′
O:To_Date
SELECT * FROM Books WHERE RegDate=To_Date('2007-05-01','yyyy-mm-dd')
6、数据类型转换
A:CStr,CInt,CDate
S:Convert,CAST
O:To_Char,To_Number,To_Date
7、Inser Into …..Select …From 语句
Insert Into a(ii,jj,kk) (Select ii,jj,kk From b)
这样的语句,在SQL Server以及Oracle中都不会有错,但在Access中会报:INSERT INTO 语句的语法错误。Access应该把后面Select语句的括号去掉,如下:
Insert Into a(ii,jj,kk) Select ii,jj,kk From b
同时这样写在SQL Server和Oracle中都不会有错
8、关键字
有些字母在Access,SQL Server中是关键字,需要用[ ]界定可解决问题,例如:at,name
9、别名
SQL Server和Oracle中字段起别名时as可以省略,Access不能
10、表名前缀
Select *,1 From A
这样的语句在Access,SQL Server中不会有错,但在Oracle中是不行的,必须要写成这样:
Select A.*,1 From A
11、如果语句中有:(冒号),例如有时间字段的查询:CalcDate=#2008-05-01 11:00:00#,在Access中一般会出现如下错误:不正常地定义参数对象。提供了不一致或不完整的信息。将相应
Query的ParamCheck 设为False即可。
12、Access中的逻辑值在库中为-1和0,而SQL Server中为1和0,所以写BoolField = 1这样的语句有兼容性问题,应该改为BoolField 0
13、Access的varchar(文本)型最大只有255,所以如果一个文本型字段大于255时,最好定义成备注型(Access中)或text型(SQL Server中)。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

This article will explain how to improve website performance by analyzing Apache logs under the Debian system. 1. Log Analysis Basics Apache log records the detailed information of all HTTP requests, including IP address, timestamp, request URL, HTTP method and response code. In Debian systems, these logs are usually located in the /var/log/apache2/access.log and /var/log/apache2/error.log directories. Understanding the log structure is the first step in effective analysis. 2. Log analysis tool You can use a variety of tools to analyze Apache logs: Command line tools: grep, awk, sed and other command line tools.

Triggers in Oracle are stored procedures used to automatically perform operations after a specific event (insert, update, or delete). They are used in a variety of scenarios, including data verification, auditing, and data maintenance. When creating a trigger, you need to specify the trigger name, association table, trigger event, and trigger time. There are two types of triggers: the BEFORE trigger is fired before the operation, and the AFTER trigger is fired after the operation. For example, the BEFORE INSERT trigger ensures that the age column of the inserted row is not negative.

To stop an Oracle database, perform the following steps: 1. Connect to the database; 2. Shutdown immediately; 3. Shutdown abort completely.

This article describes how to customize Apache's log format on Debian systems. The following steps will guide you through the configuration process: Step 1: Access the Apache configuration file The main Apache configuration file of the Debian system is usually located in /etc/apache2/apache2.conf or /etc/apache2/httpd.conf. Open the configuration file with root permissions using the following command: sudonano/etc/apache2/apache2.conf or sudonano/etc/apache2/httpd.conf Step 2: Define custom log formats to find or

Two ways to rename Oracle table names: use SQL statements: ALTER TABLE <Old table name> RENAME TO <New table name>;Use PL/SQL statements: EXECUTE IMMEDIATE 'ALTER TABLE ' || :old_table_name || ' RENAME TO ' || :new_table_name;

Oracle provides the following ways to fall back on committed database changes: Use the ROLLBACK statement to immediately revoke all uncommitted changes. Operation through the database management tool interface. Use Oracle Flashback technology to return to a specific point in time and restore data, flashback logging is required.
