Converting SQL Server code to PostgreSQL

Google Cloud Tech · Beginner ·📊 Data Analytics & Business Intelligence ·2mo ago

Key Takeaways

Google Cloud's Database Migration Service is used to convert SQL Server code to PostgreSQL, with Gemini as a trusted AI tutor, covering key differences in syntax and best practices for migration.

Full Transcript

If you've spent years writing T-SQL and SQL Server, switching to Postgres can feel extra awkward. The syntax is close, but not quite, and those small differences can really trick you up. Google Cloud's Database Migration Service acts like a hands-on translator. It lets you explore Postgres fundamentals using the schemas you already know, so you can learn faster with fewer roadblocks. [music] Here's a standard SQL Server create table statement for a products table. [music] On the right is the Postgres version that DMS generated automatically. Let's break down the key differences. [music] First up, the primary key. T-SQL uses identity for auto-incrementing IDs. DMS maps this to Postgres's identity. Is there any difference between them? Let's ask Gemini. >> [music] >> Gemini explains that DMS uses the recommended SQL standard compliant syntax, generated as identity. DMS also educates us about Postgres version differences. Until version 10, it relied on a specific pseudo type called serial to achieve this. In one click, Gemini [music] has educated and shown us the Postgres way to handle auto-incrementing keys without needing to search or guess. >> [music] >> Next, the is active column. SQL Server uses the bit data type. DMS maps it to boolean. Gemini confirms this is the idiomatic type for true false values in Postgres. A common mistake here is defaulting to an int for flags when Postgres already gives you a proper boolean type. >> [music] >> Finally, the default value for our timestamp. T-SQL uses getdate. [music] DMS maps this to Postgres's local timestamp. Local timestamp is the standard Postgres [music] function for returning the current time without time zone information at the start of the transaction. [music] That makes it the correct equivalent for getdate. DMS also notes the mapping from datetime [music] two to timestamp without time zone, which can be shortened to timestamp, to ensure precision and time zone unaware behaviors are maintained. These small, accurate translations add up. >> [music] >> With Gemini and DMS, you don't have to stop and search every unfamiliar keyword. You recognize the pattern, >> [music] >> apply what you know, and keep moving. Are you ready to start? Use the DMS conversion workspace to migrate your own SQL Server code today. The link is in the description below. >> [music] [music]

Original Description

Database Migration Service → https://goo.gle/48NKXTj Developers migrating apps to the cloud who need to convert database schemas and code to PostgreSQL, or anyone looking to improve PostgreSQL skills, can rely on Gemini as a trusted AI tutor on Google Cloud. Watch along to learn how to convert SQL Server T-SQL code into PostgreSQL while translating data types such as IDENTITY and BIT into their modern PostgreSQL equivalents. Gemini doesn't just convert code—it explains how the process works so developers can become PostgreSQL experts too. Watch more Gemini taught me PostgreSQL → https://goo.gle/ai-postgres-tutor 🔔 Subscribe to Google Cloud Tech → https://goo.gle/GoogleCloudTech #GoogleCloud #PostgreSQL Speakers: Gabe Weiss Products Mentioned: Database Migration Service, Gemini
Sign in to unlock AI tutor explanation · ⚡30

This video teaches how to convert SQL Server code to PostgreSQL using Google Cloud's Database Migration Service and Gemini as a trusted AI tutor, covering key differences in syntax and best practices for migration.

Key Takeaways
  1. Explore Postgres fundamentals using Database Migration Service
  2. Identify key differences in SQL syntax between SQL Server and PostgreSQL
  3. Use Gemini to learn about Postgres version differences and best practices
  4. Apply knowledge to convert SQL Server code to PostgreSQL
  5. Use the DMS conversion workspace to migrate own SQL Server code
💡 Small differences in SQL syntax can cause issues during migration, but using Database Migration Service and Gemini can help overcome these challenges.

Related Reads

📰
How to Format Your TDS Draft: A New and Improved Guide
Learn to format your Towards Data Science draft with a new and improved guide
Towards Data Science
📰
Retrieving Data from a Database Using SQLAlchemy ORM
Learn to efficiently retrieve data from databases using SQLAlchemy ORM, a crucial skill for data scientists and engineers
Medium · Data Science
📰
Why Consumer EEG Devices Struggle With Signal Quality (And What the Data Actually Shows)
Consumer EEG devices struggle with signal quality due to physical limitations, despite marketing claims
Medium · Data Science
📰
Governed reports with Amazon Quick Desktop and Amazon FSx for NetApp ONTAP
Learn to build a governed weekly reporting workflow using Amazon Quick Desktop and Amazon FSx for NetApp ONTAP for secure and efficient report sharing
AWS Machine Learning
Up next
A Super El Nino Is Forming...
Ryan Hall, Y'all
Watch →