DB Oracle与Access在开发中的不同之处
1. 函数名称的 不同 功能 Oracle Access 字符函数: 返回字符的 ASCII 码 ASCII(x) ASC(x) 返回 ASCII 为 X 的字符 CHR(x) CHR(x) 式化字符串 To_Char( x, format ) Format(x, format) 转换字母大小写 LOWER(x)UPPER(x) LCASE(x)UCASE(x) 求字符串长度 LENGT
1.函数名称的不同
功能 |
Oracle |
Access |
字符函数: |
|
|
返回字符的ASCII码 |
ASCII(x) |
ASC(x) |
返回ASCII为X的字符 |
CHR(x) |
CHR(x) |
格式化字符串 |
To_Char( x, format ) |
Format(x, format) |
转换字母大小写 |
LOWER(x) UPPER(x) |
LCASE(x) UCASE(x) |
求字符串长度 |
LENGTH(x) |
LEN(x) |
去除字符串中的空格 |
LTRIM(x[, trim_string]), RTRIM(x[,trim_string]) TRIM([trim_string From ]x) |
LTRIM(x) RTRIM(x) TRIM(x) |
取子字符串 |
SUBSTR(x, start[,length]) |
LEFT(x, length) MID(x,start,length) RIGHT(x,length) |
转换函数: |
|
|
如果X与search相等,返回result,否则,返回default |
Decode(x, search,result,default) |
IIF(x=search, result, default) |
将数字转换为字符串 |
To_Char(x) |
CStr(x) |
将字符串转换为数字 |
To_Number(x) |
CDbl() --转换为dbouble |
如果ColName为空,返回result,否则,返回ColName的值。 |
NVL(ColName, result) |
IIF(IsNull(ColName), result, ColName) |
日期函数: |
|
|
当前系统时间(日期小时分秒) |
sysdate |
NOW() |
当前日期 |
Trunc(sysdate) |
DATE() |
当前时间 |
-- |
TIME() |
返回时间的某个部分 |
To_Char( sysdate, ‘yyyy’ ) To_Char( sysdate, ‘mm’ ) To_Char( sysdate, ‘dd’ ) To_Char( sysdate, ‘hh’ ) To_Char( sysdate, ‘mi’ ) To_Char( sysdate, ‘ss’ ) Extract( Year From Sysdate ) Extract( Month From Sysdate) Extract( Day From Sysdate) Extract( Hour From TimeStamp '2007-09-27 0:0:0') Extract( Minute From TimeStamp '2007-09--27 23:59:59') |
Year(now()) Month(now()) Day(now()) Hour(now()) Minute(now()) Second(now()) DatePart(format, now()) |
将字符串转换为日期 |
To_Date( x, format ) |
CDate(x ) #date_string# |
2.SQL语句实现的差别
1、Oracle支持连续的Left Join,但是Access不支持。
Access实现Oracle的连续两个Left Join的方法:
Select * From TblA Left Join
(Select * From TblB Left Join TblC )
2、Access给字段起别名是必须用AS,但是Oracle不用AS也可以,建议起别名全部都用AS
3、Oracle可以使用 Select Count( Distinct ColumnName ) From…..的语法,但是Access中不可以。Access中要实现这样的功能,要使用嵌套查询:
Select Count(*) From
( Select Distinct ColumnName From Tbl….)
4、Oracle中,如果TblA Left Join TblB,那么结果集是TblA中数据的数量。但是在Access中,TblA Left Join TblB,结果集的数量是TblA* TblB的数量。
5、在Oracle中,用一条SQL向一个递增的字段插入数据可以使用如下SQL:
Insert Into TblA ( N_ID ) Values ( ( Select ( Nvl( Max(N_ID), 0 )+1 ) from TblA ) );
但是由于函数的不同,在Access中需要使用下面的SQL:
Insert Into TblA( N_ID ) Values ( IIF( IsNull(DLookUp( ‘Max(N_ID)+1’, ‘TblA’, ‘’ ) ), 1, DLookUp( ‘Max(N_ID)+1’, ‘TblA’, ‘’ ) ) );
DLookUp是Access的一个内置的函数,使用方法为:
DLookup("字段名称" , "表或查询名称" , "条件")
返回的结果为:从根据“条件”,从“表或查询名称”中查出“字段名称”的值。
3.使用Delphi时遇到的一些问题的解决办法
1、不正常地定义参数对象。提供了不一致或不完整的信息
这个错误经常出现在操作Access数据库的日期字段时发生。原因为,Delphi默认将:X认为是一个参数,而Access中的时间可以表示为#2007-01-01 10:11:12#,这样,Delphi在解析这个字符串时会出问题。
解决方法有两个:
1 在给TADOQuery对象的SQL属性赋值前,先调用qry.ParamCheck := True;然后再执行后续操作。在操作完成后,执行qry.ParamCheck := False,恢复默认设置。
2 SQL语句中,将日期类型的字段全部作为参数来操作,例如:
sSql := ‘Insert Into TblA ( D_Date ) values (:D_Date)’;
qry.SQL.Text := sSql;
qry.ParamByName(‘D_Date’).Value := DateValue;
2、类似于“不可更新的查询”的错误。
Access数据库是只读的,更改使其为可写即可。

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



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.

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.

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.

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;

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

Escape characters in Oracle are used to indicate special characters or control sequences, including line connections, string delimiters, line breaks, carriage return, tabs, and backspace characters. Escape character processing usually involves escaping special characters in a string, using | concatenating multiline strings, and using a backslash to escape the escape character itself.
