Table of Contents
2.SQL语句实现的差别
3.使用Delphi时遇到的一些问题的解决办法
Home Database Mysql Tutorial DB Oracle与Access在开发中的不同之处

DB Oracle与Access在开发中的不同之处

Jun 07, 2016 pm 03:31 PM
access oracle different function develop

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)

       返回ASCIIX的字符

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)

转换函数:

 

 

       如果Xsearch相等,返回result,否则,返回default

Decode(x, search,result,default)

IIF(x=search, result, default)

       将数字转换为字符串

To_Char(x)

CStr(x)

       将字符串转换为数字

To_Number(x)

CDbl()    --转换为dbouble 
CInt()    --
转换为int 
CLng()    --
转换为long int 
CBool()   --
转换为boolean

       如果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语句实现的差别

1Oracle支持连续的Left Join,但是Access不支持。

       Access实现Oracle的连续两个Left Join的方法:

       Select * From TblA Left Join

(Select * From TblB Left Join TblC )

 

2Access给字段起别名是必须用AS,但是Oracle不用AS也可以,建议起别名全部都用AS

 

3Oracle可以使用 Select Count( Distinct ColumnName ) From…..的语法,但是Access中不可以。Access中要实现这样的功能,要使用嵌套查询:

       Select Count(*) From

( Select Distinct ColumnName From Tbl….)

 

4Oracle中,如果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’, ‘’ ) ) );

 

DLookUpAccess的一个内置的函数,使用方法为:

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数据库是只读的,更改使其为可写即可。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to configure zend for apache How to configure zend for apache Apr 13, 2025 pm 12:57 PM

How to configure Zend in Apache? The steps to configure Zend Framework in an Apache Web Server are as follows: Install Zend Framework and extract it into the Web Server directory. Create a .htaccess file. Create the Zend application directory and add the index.php file. Configure the Zend application (application.ini). Restart the Apache Web server.

What steps are required to configure CentOS in HDFS What steps are required to configure CentOS in HDFS Apr 14, 2025 pm 06:42 PM

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

How to use Debian Apache logs to improve website performance How to use Debian Apache logs to improve website performance Apr 12, 2025 pm 11:36 PM

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.

What is apache server? What is apache server for? What is apache server? What is apache server for? Apr 13, 2025 am 11:57 AM

Apache server is a powerful web server software that acts as a bridge between browsers and website servers. 1. It handles HTTP requests and returns web page content based on requests; 2. Modular design allows extended functions, such as support for SSL encryption and dynamic web pages; 3. Configuration files (such as virtual host configurations) need to be carefully set to avoid security vulnerabilities, and optimize performance parameters, such as thread count and timeout time, in order to build high-performance and secure web applications.

Using Dicr/Yii2-Google to integrate Google API in YII2 Using Dicr/Yii2-Google to integrate Google API in YII2 Apr 18, 2025 am 11:54 AM

VprocesserazrabotkiveB-enclosed, Мнепришлостольностьсясзадачейтерациигооглапидляпапакробоглесхетсigootrive. LEAVALLYSUMBALLANCEFRIABLANCEFAUMDOPTOMATIFICATION, ČtookazaLovnetakProsto, Kakaožidal.Posenesko

How to configure the database connection of weblogic on centos How to configure the database connection of weblogic on centos Apr 14, 2025 pm 02:06 PM

Configuring WebLogic database connection on a CentOS system requires the following steps: JDK installation and environment configuration: Make sure that the server has installed a JDK that is compatible with the WebLogic version (for example, WebLogic14.1.1 usually requires JDK8). Correctly set JAVA_HOME, CLASSPATH and PATH environment variables. WebLogic installation and decompression: Download the WebLogic installation package for CentOS system from the official Oracle website and unzip it to the specified directory. WebLogic user and directory creation: Create a dedicated WebLogic user account and set a security password

Nginx performance monitoring and troubleshooting tools Nginx performance monitoring and troubleshooting tools Apr 13, 2025 pm 10:00 PM

Nginx performance monitoring and troubleshooting are mainly carried out through the following steps: 1. Use nginx-V to view version information, and enable the stub_status module to monitor the number of active connections, requests and cache hit rate; 2. Use top command to monitor system resource occupation, iostat and vmstat monitor disk I/O and memory usage respectively; 3. Use tcpdump to capture packets to analyze network traffic and troubleshoot network connection problems; 4. Properly configure the number of worker processes to avoid insufficient concurrent processing capabilities or excessive process context switching overhead; 5. Correctly configure Nginx cache to avoid improper cache size settings; 6. By analyzing Nginx logs, such as using awk and grep commands or ELK

Oracle's Role in the Business World Oracle's Role in the Business World Apr 23, 2025 am 12:01 AM

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

See all articles