Sql Server to Aurora Postgresql Migration Playbook
Total Page:16
File Type:pdf, Size:1020Kb
Microsoft SQL Server To Amazon Aurora with Post- greSQL Compatibility Migration Playbook 1.0 Preliminary September 2018 © 2018 Amazon Web Services, Inc. or its affiliates. All rights reserved. Notices This document is provided for informational purposes only. It represents AWS’s current product offer- ings and practices as of the date of issue of this document, which are subject to change without notice. Customers are responsible for making their own independent assessment of the information in this document and any use of AWS’s products or services, each of which is provided “as is” without war- ranty of any kind, whether express or implied. This document does not create any warranties, rep- resentations, contractual commitments, conditions or assurances from AWS, its affiliates, suppliers or licensors. The responsibilities and liabilities of AWS to its customers are controlled by AWS agree- ments, and this document is not part of, nor does it modify, any agreement between AWS and its cus- tomers. - 2 - Table of Contents Introduction 9 Tables of Feature Compatibility 12 AWS Schema and Data Migration Tools 20 AWS Schema Conversion Tool (SCT) 21 Overview 21 Migrating a Database 21 SCT Action Code Index 31 Creating Tables 32 Data Types 32 Collations 33 PIVOT and UNPIVOT 33 TOP and FETCH 34 Cursors 34 Flow Control 35 Transaction Isolation 35 Stored Procedures 36 Triggers 36 MERGE 37 Query hints and plan guides 37 Full Text Search 38 Indexes 38 Partitioning 39 Backup 40 SQL Server Mail 40 SQL Server Agent 41 Service Broker 41 XML 42 Constraints 42 - 3 - Linked Servers 42 AWS Database Migration Service (DMS) 43 Overview 43 Migration Tasks Performed by AWS DMS 43 How AWS DMS Works 44 ANSI SQL 46 Migrate from: SQL Server Constraints 47 Migrate to: Aurora PostgreSQL Table Constraints 51 Migrate from: SQL Server Creating Tables 58 Migrate to: Aurora PostgreSQL Creating Tables 62 Migrate from: SQL Server Common Table Expressions 67 Migrate to: Aurora PostgreSQL Common Table Expressions (CTE) 70 Migrate from: SQL Server Data Types 74 Migrate to: Aurora PostgreSQL Data Types 76 Migrate from: SQL Server Derived Tables 81 Migrate to: Aurora PostgreSQL Derived Tables 82 Migrate from: SQL Server GROUP BY 83 Migrate to: Aurora PostgreSQL GROUP BY 87 Migrate from: SQL Server Table JOIN 90 Migrate to: Aurora PostgreSQL Table JOIN 95 Migrate from: SQL Server Temporal Tables 99 Migrate to: Aurora PostgreSQL Triggers (Temporal Tables alternative) 101 Migrate from: SQL Server Views 102 Migrate to: Aurora PostgreSQL Views 105 Migrate from: SQL Server Window Functions 108 Migrate to: Aurora PostgreSQL Window Functions 110 T-SQL 114 Migrate from: SQL Server Service Broker Essentials 115 Migrate to: Aurora PostgreSQL AWS Lambda or DB links 119 Migrate from: SQL Server Cast and Convert 120 - 4 - Migrate to: Aurora PostgreSQL CAST and CONVERSION 122 Migrate from: SQL Server Common Library Runtime (CLR) 124 Migrate to: Aurora PostgreSQL PL/Perl 125 Migrate from: SQL Server Collations 126 Migrate to: Aurora PostgreSQL Encoding 129 Migrate from: SQL Server Cursors 132 Migrate to: Aurora PostgreSQL Cursors 134 Migrate from: SQL Server Date and Time Functions 139 Migrate to: Aurora PostgreSQL Date and Time Functions 141 Migrate from: SQL Server String Functions 143 Migrate to: Aurora PostgreSQL String Functions 145 Migrate from: SQL Server Databases and Schemas 148 Migrate to: Aurora PostgreSQL Databases and Schemas 151 Migrate from: SQL Server Dynamic SQL 153 Migrate to: Aurora PostgreSQL EXECUTE and PREPARE 156 Migrate from: SQL Server Transactions 159 Migrate to: Aurora PostgreSQL Transactions 163 Migrate from: SQL Server Synonyms 169 Migrate to: Aurora PostgreSQL Views, Types & Functions 171 Migrate from: SQL Server DELETE and UPDATE FROM 173 Migrate to: Aurora PostgreSQL DELETE and UPDATE FROM 176 Migrate from: SQL Server Stored Procedures 179 Migrate to: Aurora PostgreSQL Stored Procedures 182 Migrate from: SQL Server Error Handling 186 Migrate to: Aurora PostgreSQL Error Handling 191 Migrate from: SQL Server Flow Control 194 Migrate to: Aurora PostgreSQL Control Structures 197 Migrate from: SQL Server Full-Text Search 200 Migrate to: Aurora PostgreSQL Full-Text Search 203 Migrate from: SQL Server JSON and XML 206 - 5 - Migrate to: Aurora PostgreSQL JSON and XML 209 Migrate from: SQL Server MERGE 213 Migrate to: Aurora PostgreSQL MERGE 216 Migrate from: SQL Server PIVOT and UNPIVOT 218 Migrate to: Aurora PostgreSQL PIVOT and UNPIVOT 222 Migrate from: SQL Server Triggers 225 Migrate to: Aurora PostgreSQL Triggers 228 Migrate from: SQL Server TOP and FETCH 232 Migrate to: Aurora PostgreSQL LIMIT and OFFSET (TOP and FETCH Equivalent) 235 Migrate from: SQL Server User Defined Functions 238 Migrate to: Aurora PostgreSQL User Defined Functions 241 Migrate from: SQL Server User Defined Types 242 Migrate to: Aurora PostgreSQL User Defined Types 245 Migrate from: SQL Server Sequences and Identity 248 Migrate to: Aurora PostgreSQL Sequences and SERIAL 253 Configuration 258 Migrate from: SQL Server Session Options 259 Migrate to: Aurora PostgreSQL Session Options 262 Migrate from: SQL Server Database Options 265 Migrate to: Aurora PostgreSQL Database Options 266 Migrate from: SQL Server Server Options 267 Migrate to: Aurora PostgreSQL Aurora Parameter Groups 269 High Availability and Disaster Recovery (HADR) 276 Migrate from: SQL Server Backup and Restore 277 Migrate to: Aurora PostgreSQL Backup and Restore 281 Migrate from: SQL Server High Availability Essentials 289 Migrate to: Aurora PostgreSQL High Availability Essentials 293 Indexes 303 Migrate from: SQL Server Clustered and Non Clustered Indexes 304 Migrate to: Aurora PostgreSQL Clustered and Non Clustered Indexes 308 - 6 - Management 313 Migrate from: SQL Server Agent 314 Migrate to: Aurora PostgreSQL Scheduled Lambda 315 Migrate from: SQL Server Alerting 316 Migrate to: Aurora PostgreSQL Alerting 318 Migrate from: SQL Server Database Mail 323 Migrate to: Aurora PostgreSQL Database Mail 326 Migrate from: SQL Server ETL 334 Migrate to: Aurora PostgreSQL ETL 336 Migrate from: SQL Server Export and Import with Text files 361 Migrate to: Aurora PostgreSQL pg_dump and pg_restore 363 Migrate from: SQL Server Viewing Server Logs 366 Migrate to: Aurora PostgreSQL Viewing Server Logs 368 Migrate from: SQL Server Maintenance Plans 371 Migrate to: Aurora PostgreSQL Maintenance Plans 373 Migrate from: SQL Server Monitoring 378 Migrate to: Aurora PostgreSQL Monitoring 381 Migrate from: SQL Server Resource Governor 383 Migrate to: Aurora PostgreSQL Dedicated Amazon Aurora Clusters 385 Migrate from: SQL Server Linked Servers 388 Migrate to: Aurora PostgreSQL DBLink and FDWrapper 391 Migrate from: SQL Server Scripting 393 Migrate to: Aurora PostgreSQL Scripting 395 Performance Tuning 399 Migrate from: SQL Server Execution Plans 400 Migrate to: Aurora PostgreSQL Execution Plans 402 Migrate from: SQL Server Query Hints and Plan Guides 404 Migrate to: Aurora PostgreSQL DB Query Planning 408 Migrate from: SQL Server Managing Statistics 409 Migrate to: Aurora PostgreSQL Table Statistics 411 - 7 - Physical Storage 414 Migrate from: SQL Server Columnstore Index 415 Migrate to: Aurora PostgreSQL 416 Migrate from: SQL Server Indexed Views 417 Migrate to: Aurora PostgreSQL Materialized Views 419 Migrate from: SQL Server Partitioning 422 Migrate to: Aurora PostgreSQL Table Inheritance 424 Security 429 Migrate from: SQL Server Column Encryption 430 Migrate to: Aurora PostgreSQL Column Encryption 432 Migrate from: SQL Server Data Control Language 434 Migrate to: Aurora PostgreSQL Data Control Language 435 Migrate from: SQL Server Transparent Data Encryption 438 Migrate to: Aurora PostgreSQL Transparent Data Encryption 439 Migrate from: SQL Server Users and Roles 444 Migrate to: Aurora PostgreSQL Users and Roles 446 Appendix A: SQL Server 2018 Deprecated Feature List 448 Migration Quick Tips 449 Migration Quick Tips 450 Management 450 SQL 450 Glossary 453 - 8 - Introduction The migration process from SQL Server to Amazon Aurora PostgreSQL typically involves several stages. The first stage is to use the AWS Schema Conversion Tool (SCT) and the AWS Database Migration Ser- vice (DMS) to convert and migrate the schema and data. While most of the migration work can be auto- mated, some aspects require manual intervention and adjustments to both database schema objects and database code. The purpose of this Playbook is to assist administrators tasked with migrating SQL Server databases to Aurora PostgreSQL with the aspects that can't be automatically migrated using the Amazon Web Ser- vices Schema Conversion Tool (AWS SCT). It focuses on the differences, incompatibilities, and sim- ilarities between SQL Server and Aurora PostgreSQL in a wide range of topics including T-SQL, Configuration, High Availability and Disaster Recovery (HADR), Indexing, Management, Performance Tuning, Security, and Physical Storage. The first section of this document provides an overview of AWS SCT and the AWS Data Migration Ser- vice (DMS) tools for automating the migration of schema, objects and data. The remainder of the doc- ument contains individual sections for SQL Server features and their Aurora PostgreSQL counterparts. Each section provides a short overview of the feature, examples, and potential workaround solutions for incompatibilities. You can use this playbook either as a reference to investigate the individual action codes generated by the AWS SCT tool, or to explore a variety of topics where you expect to have some incompatibility issues. When