Home Database Mysql Tutorial 将现有的Access数据库升级为SQL_MySQL

将现有的Access数据库升级为SQL_MySQL

Jun 01, 2016 pm 02:05 PM
server sql upgrade database have Inquire sheet

Access

很多Access和SQL Server开发人员都经常面临着将一个Access数据库升级到SQL Server数据库的问题。由于存在现有的Access升级向导,这一转变的过程就会变得相当简单,尤其是当你建立一个与SQL Server数据相联系的ADP的时候。然而,向导并不是十全十美的,需要解决的问题还是大有存在。


首先,有些对象并不是简单的升级,所以这时你不得不人为地处理。第二,很多Access特性──比如一些查询类型,对象,以及特定的数据类型在你没有做好升级之前的准备的情况下就会导致错误的产生。现在,让我们讨论一下在数据库升级过程中可能面临的问题,我将提供能够解决问题的一些通用的指导方法,最后,你必须花一定的时间和精力将这些知识应用到开发之中。

哪些不能够升级?
在处理实际的问题之前,让我们看看不能随意升级的对象,它们包括以下:

交叉表查询
包含SQL DISTINCTROW关键字的任何查询
所有的隐藏对象
作为参数的表格数据的查询(这些表格可以升级,但它们却不能正确的运行)
Pass-Through查询
SQL数据定义语言查询(比如CREATE TABLE, ALTER TABLE, 以及DROP语句)
这些Access对象需要特定的处理。具体的,你将建立一个可比较的SQL Server对象,除此之外,SQL Server不支持Jet安全特性,所以你必须使用Windows认证和/或SQL Server安全机制。

包括的问题点
在数据库的升级之前,如果你已经知道哪些地方将可能导致错误并知道如何处理产生的错误,数据库升级过程中导致的错误的可能性将大大地减少。我能够提供的数据库升级的最好的建议是在开发之前做好最完整的计划。现在,我将列举数据库升级过程中可能会导致产生的问题──如果你没有做好计划之前的准备。

不支持的日期

关于日期,在Access和SQL Server之间都存在很大的差别。Access支持很大范围的日期,从100年1月1日到9999年12月31日。相反,SQL Server支持的日期从1753年1月1日到9999年12月31日。数据库的升级向导无法升级包含SQL Server不支持的日期的表格。这就意味着在升级之前你必须人工地处理这些日期。幸运的是,这一问题只影响少数的数据库。

与表格控制相关的查询
开发人员通常会使用表格控制的查询来限制或询问一个数据来源。一个表格可以提供将数据显示在一个特定报告中的多种选择。例如,SQL SELECT语句包含了用户的输入:

SELECT Orders.RequiredDate, Orders.ShippedDate, Orders.Freight,
Orders.ShipName, Orders.ShipAddress, Orders.OrderDate
FROM Orders
WHERE
Orders.OrderDate Between [Forms]![DateFilter]![DateFrom] And [Forms]![DateFilter]![DateTo]));

为了限定报告中的数据,用户可以输入一个开始和结束的日期到列表(DateFrom 和DateTo)。其他的代码可以打开并显示满足用户输入的两个日期之间的记录。

因为这种查询方式被Jet处理,表格中产生的问题可以很快被解决。然而,当数据库升级时,SQL Server不会涉及到表格控制,结果通常为查询失败。为了修正这一查询方式,开发人员必须更改表格。我建议你使用输入参数属性,并将数值传递到SQL Server存储程序。

交叉表查询
SQL Server不支持Jet TRANSFORM语句──这一语句可以使一个交叉表查询成为可能。例如,数据库升级向导支持以下查询方式:

TRANSFORM Sum(CCur([Order Details].UnitPrice*[Quantity]*(1-[Discount])/100)*100)
AS ProductAmount
SELECT Products.ProductName, Orders.CustomerID, Year([OrderDate]) AS OrderYear
FROM Products INNER JOIN (Orders INNER JOIN [Order Details]
ON Orders.OrderID = [Order Details].OrderID) ON Products.ProductID =
[Order Details].ProductID
WHERE Orders.OrderDate Between #1/1/1997# And #12/31/1997#
GROUP BY Products.ProductName, Orders.CustomerID, Year([OrderDate])
PIVOT "Qtr " & DatePart("q",[OrderDate],1,0) In ("Qtr 1","Qtr 2","Qtr 3","Qtr 4")

还好,你无需在SQL Server中使用Transact-SQL (T-SQL) CASE关键词重新编写一个Access的交叉表查询。下面的SELECT语句描述了使用T-SQL方式重新建立一个交叉表查询的语法:

SELECT Customers.CustomerID, Customers.CustomerName
SUM (Case When Orders.Orderdate BETWEEN '01-Jan-1990' AND '31-Dec-1996'
Then [UnitPrice]*[Quantity] Else 0 End) as 1997)
FROM Customers INNER JOIN Orders
ON CustomerID=Orders.CustomerID

隐藏对象
所有的隐藏对象在数据库升级过程中都被忽略。对此,你最好的处理方法是使用程序对象的GetHiddenAttribute属性检查对象。例如,以下代码使用这一方法决定对象是否被隐藏。
Dim IsHidden As Boolean
If Application.GetHiddenAttribute(objtype, objname) Then
IsHidden = True
End If

如果特定的对象被隐藏,IsHidden布尔变量将被为True。

包含索引的表格

数据库升级向导不支持没有索引或其他限制的表格。升级向导可以升级一个无索引的表格,但其转换之后只能成为一个只读的表格。幸运的是,解决这一问题很简单:添加一个索引到每一个没有索引的表格。一旦你已经完成升级数据库,请记住将添加的索引删除。

数据库升级操作步骤
一旦你已经做好一切准备,并确定操作可以开始。数据库升级向导可以为你提供三种选择:

输出Access表格到SQL Server并链接到Access数据库
使用Pass-Through查询与SQL Server的后台服务器的表格相互通讯
将整个Access数据库移动到一个Access数据库工程(其只与SQL Server联系)
为了启动数据库升级向导,先从工具菜单栏中选择数据库功能,然后从子菜单中选择升级向导。向导的第一个面板提供两种选择:你可以建立一个新的SQL Server 数据库来存放Access表格,如图A所示,或者你可以在一个现成的SQL Server数据库中添加表格。选择一个现成的SQL Server数据库将需要输入一个数据服务名称(DSN)。

图 A

将现有的Access数据库升级为SQL_MySQL

选择建立一个新的数据库或者使用一个现成的数据库
第二个面板要求获得SQL Server范例的信息。除此之外,你必须认证安全机制(如果存在)和为新的数据库提供一个缺省的名称,如图B所示。
图B

将现有的Access数据库升级为SQL_MySQL

为一个新的数据库命名

在这点上,你可以将需要的表格复制到SQL Server,你也可以指出完成的部分将成为一个完整的ADP或者一个被链接的表格,如图C所示。

图 C

将现有的Access数据库升级为SQL_MySQL

指明一个ADP或者一个被链接的表格


避开麻烦

每一个开发人员都有不同的数据库升级操作的经验,所以无法保证第一次操作就能够达到成功。然而,如果你遵循本文中提供的有关规则,你应该遇到更少的错误,即使碰到,你也可以很容易地修正错误,并继续操作。


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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

What is the difference between HQL and SQL in Hibernate framework? What is the difference between HQL and SQL in Hibernate framework? Apr 17, 2024 pm 02:57 PM

HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

How to check your academic qualifications on Xuexin.com How to check your academic qualifications on Xuexin.com Mar 28, 2024 pm 04:31 PM

How to check my academic qualifications on Xuexin.com? You can check your academic qualifications on Xuexin.com, but many users don’t know how to check their academic qualifications on Xuexin.com. Next, the editor brings you a graphic tutorial on how to check your academic qualifications on Xuexin.com. Interested users come and take a look! Xuexin.com usage tutorial: How to check your academic qualifications on Xuexin.com 1. Xuexin.com entrance: https://www.chsi.com.cn/ 2. Website query: Step 1: Click on the Xuexin.com address above to enter the homepage Click [Education Query]; Step 2: On the latest webpage, click [Query] as shown by the arrow in the figure below; Step 3: Then click [Login Academic Credit File] on the new page; Step 4: On the login page Enter the information and click [Login];

12306 How to check historical ticket purchase records How to check historical ticket purchase records 12306 How to check historical ticket purchase records How to check historical ticket purchase records Mar 28, 2024 pm 03:11 PM

Download the latest version of 12306 ticket booking app. It is a travel ticket purchasing software that everyone is very satisfied with. It is very convenient to go wherever you want. There are many ticket sources provided in the software. You only need to pass real-name authentication to purchase tickets online. All users You can easily buy travel tickets and air tickets and enjoy different discounts. You can also start booking reservations in advance to grab tickets. You can book hotels or special car transfers. With it, you can go where you want to go and buy tickets with one click. Traveling is simpler and more convenient, making everyone's travel experience more comfortable. Now the editor details it online Provides 12306 users with a way to view historical ticket purchase records. 1. Open Railway 12306, click My in the lower right corner, and click My Order 2. Click Paid on the order page. 3. On the paid page

Xiaoyi upgraded to an intelligent agent! HarmonyOS NEXT Hongmeng native intelligence opens a new AI era Xiaoyi upgraded to an intelligent agent! HarmonyOS NEXT Hongmeng native intelligence opens a new AI era Jun 22, 2024 am 01:56 AM

On June 21, Huawei Developer Conference 2024 (HDC2024) gathered again in Songshan Lake, Dongguan. At this conference, the most eye-catching thing is that HarmonyOSNEXT officially launched Beta for developers and pioneer users, and comprehensively demonstrated the three "king-breaking" innovative features of HarmonyOSNEXT in all scenarios, native intelligence and native security. HarmonyOSNEXT native intelligence: Opening a new AI era After abandoning the Android framework, HarmonyOSNEXT has become a truly independent operating system independent of Android and iOS, which can be called an unprecedented rebirth. Among its many new features, native intelligence is undoubtedly the new feature that can best bring users intuitive feelings and experience upgrades.

I upgraded arise account registration by myself and shared graphic tutorials I upgraded arise account registration by myself and shared graphic tutorials Mar 28, 2024 pm 01:16 PM

How do I register an account when I upgrade arise alone? I Upgrade Arise Alone is an action-adventure RPG adapted from the popular comic book of the same name. Currently, the game has started external testing. Many players want to experience it. Here is an introduction to how to register a game account. I hope it will be helpful to everyone. [Registration Method] To register an account, you can choose Google, Apple or email to log in. It is recommended that players choose to register with an email account. [Detailed steps] 1. First, select the last email address in the account binding interface to log in, then jump to the email registration interface, and directly click the email address in the picture below to register. 2. After entering the registration email page, enter the email number, set the login password and click Next. 3. Then bind the recovery email. The function of the recovery email: you can use the email recovery function after the account is lost.

The best time to buy Huawei Mate 60 series, new AI elimination + image upgrade, and enjoy autumn promotions The best time to buy Huawei Mate 60 series, new AI elimination + image upgrade, and enjoy autumn promotions Aug 29, 2024 pm 03:33 PM

Since the Huawei Mate60 series went on sale last year, I personally have been using the Mate60Pro as my main phone. In nearly a year, Huawei Mate60Pro has undergone multiple OTA upgrades, and the overall experience has been significantly improved, giving people a feeling of being constantly new. For example, recently, the Huawei Mate60 series has once again received a major upgrade in imaging capabilities. The first is the new AI elimination function, which can intelligently eliminate passers-by and debris and automatically fill in the blank areas; secondly, the color accuracy and telephoto clarity of the main camera have been significantly upgraded. Considering that it is the back-to-school season, Huawei Mate60 series has also launched an autumn promotion: you can enjoy a discount of up to 800 yuan when purchasing the phone, and the starting price is as low as 4,999 yuan. Commonly used and often new products with great value

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How does Hibernate implement polymorphic mapping? How does Hibernate implement polymorphic mapping? Apr 17, 2024 pm 12:09 PM

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

See all articles