Designing Data Storage Architecture-SQL Azure differences
2011-12-29 09:57
609 查看
http://sqlblog.com/blogs/john_paul_cook/archive/2010/09/12/sql-azure-differences.aspx
SQL Azure differences
If you prefer wizards and designers, SQL Azure may cause you some frustration because they’re not there. But if you like T-SQL scripting, you’ll be in your element with SQL Azure. Here’s what happens in SQL Azure when you try to create a new table:![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/16/5e34999ad6d5e09ab51eeeb08bea427e.png)
Since it’s likely that existing SQL Server scripts will be used to create tables in SQL Azure, I decided to put a script to the test. In SQL Server 2008 R2, I created a table that has one column for every SQL Server data type. I scripted the table and tried
to run the script on SQL Azure.
CREATE
TABLE dbo.allDatatypes(
abigint bigint NULL,
abinary binary(50) NULL,
abit bit NULL,
achar char(10) NULL,
adate date NULL,
adatetime datetime NULL,
adatetime2 datetime2(7) NULL,
adatetimeoffset datetimeoffset(7) NULL,
adecimal decimal(18, 0) NULL,
afloat float NULL,
ageography geography NULL,
ageometry geometry NULL,
ahierarchyid hierarchyid NULL,
aimage image NULL,
aint int NULL,
amoney money NULL,
anchar nchar(10) NULL,
antext ntext NULL,
anumeric numeric(18, 0) NULL,
anvarchar50 nvarchar(50) NULL,
anvarcharMAX nvarchar(max) NULL,
areal real NULL,
asmalldatetime smalldatetime NULL,
asmallint smallint NULL,
asmallmoney smallmoney NULL,
asql_variant sql_variant NULL,
atext text NULL,
atime time(7) NULL,
atimestamp timestamp NULL,
atinyint tinyint NULL,
auniqueidentifier uniqueidentifier NOT NULL,
avarbinary50 varbinary(50) NULL,
avarbinaryMAX varbinary(max) NULL,
avarchar50 varchar(50) NULL,
avarcharMAX varchar(max) NULL,
axml xml NULL
) ON PRIMARY TEXTIMAGE_ON PRIMARY
Msg 156, Level 15, State 1, Line 40
Incorrect syntax near the keyword 'PRIMARY'.
It didn’t work because
SQL Azure abstracts away filegroups, which probably doesn’t bother people who only use the defaults for filegroups.
Removing ON PRIMARY TEXTIMAGE_ON PRIMARY allows the script to run successfully on SQL Azure.
Although geography, geometry, and hierarchyid are implemented with the CLR,
user defined CLR is not allowed in SQL Azure. As we can see from running the corrected script, SQL Azure supports all SQL Server data types, but that doesn’t mean everything works exactly the same way as it does on SQL Server.
If you need to insert guids, newsequentialid() is very helpful in preventing index page splits during inserts.
It’s not supported in SQL Azure, so you’ll have to use newid() instead.
auniqueidentifier uniqueidentifier NOT NULL default newsequentialid(),
Msg 40511, Level 15, State 1, Line 32
Built-in function 'newsequentialid' is not supported in this version of SQL Server.
Also, ROWGUIDCOL is not supported.
auniqueidentifier uniqueidentifier NOT NULL ROWGUIDCOL,
Msg 40514, Level 16, State 6, Line 1
'ROW GUID COLUMN' is not supported in this version of SQL Server.
You can’t use extended properties to document a table in SQL Azure. Most people don’t do this, so it’s not a big deal.
EXEC
sp_addextendedproperty N'MS_Description', N'This
column is used as the primary key.'
, 'SCHEMA', N'dbo'
, 'TABLE', N'allDataTypes'
, 'COLUMN', N'_uniqueidentifier'
GO
Msg 2812, Level 16, State 62, Line 1
Could not find stored procedure 'sp_addextendedproperty'.
Given this background, you know to expect some differences between the SQL Server version of the AdventureWorksLT database and the SQL Azure version. Since we are so familiar with AdventureWorks databases and there are so many examples written based on them,
it’s important to know how similar the SQL Azure version is. This isn’t such an easy thing to do today because of a lack of SQL Azure compatible tools. Using a special build of SQL Compare that
Red Gate provided to me (take the link and answer the survey to get your own copy), I was able to get a nice visual representation of the differences.
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/16/b91dbdb637e42148ce3fe2c03d4cbb40.png)
We can see several differences including a lack of triggers and foreign keys in the SQL Azure version of AdventureWorks. This could lead you to
the erroneous conclusion that triggers and foreign keys are not supported in SQL Azure. Rest assured, they are supported. I ran the scripts to create the triggers and foreign keys in AdventureWorksLTAZ2008R2
and they worked just fine.
Other differences between SQL Server and SQL Azure can be seen in right-click menu options. I think Arnie and Allen are probably upset about the lack of PowerShell support.
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/16/2af81db17340794d0801aca026230e6e.png)
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/16/90ec2b47b91f23af3cd70eeb638720c8.png)
Full-Text Indexes, Policies, and Facets are not supported in SQL Azure.
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/16/11c55da83c2b36942effbb7d2a6f094b.png)
![](https://oscdn.geek-share.com/Uploads/Images/Content/202003/16/0e1dcc991f6708be9d677ff2aa389643.png)
相关文章推荐
- Designing Data Storage Architecture- How to Sync Large SQL Server Databases to SQL Azure
- Designing Data Storage Architecture-7 Things You Need To Know about SQL Azure Reporting
- Designing Data Storage Architecture-Windows Azure Storage Abstractions and their Scalability Targets
- Designing Data Storage Architecture - SQL Azure - why use it and what makes it different from SQL se
- Designing Data Storage Architecture-Using the Windows Azure Storage Services
- Designing Data Storage Architecture - Introducing the Windows Azure Content Delivery Network
- Designing Data Storage Architecture-the data storage offerings available on the Windows Azure platfo
- Designing Data Storage Architecture-Azure Storage Options
- Designing Data Storage Architecture - datasync
- Designing the Application Architecture - Transact-SQL Support (SQL Azure Database)
- Designing Data Storage Architecture - Understanding Block Blobs and Page Blobs
- Comparing Azure storage and SQL Data Services
- Designing Data Storage Architecture - Pricing Overview
- Optimizing Data Access and Messaging - SQL Azure Connection Management
- 【FWD】Windows Azure Table Storage vs. Windows SQL Azure
- 使用Azure SQL Data Sync在Azure 上实现蓝绿部署
- 【Azure Services Platform Step by Step-第4篇】SQL Data Services 编程基础
- SQL Azure(十) SQL Azure Data Sync数据同步功能(上)
- Using the default SQL Server instance for Windows Azure development storage
- 【Azure Services Platform Step by Step-第2篇】忘掉SQL Server 200X——Introducing SQL Data Services(SDS)[现已更名为SQL Azure]