Database Migration Service migrates only tables that have primary keys.
If your source database includes tables that don't have primary keys,
you need to manually create primary key constraints in the converted tables
in the destination database after you
[apply the converted schema](https://docs.cloud.google.com/database-migration/docs/sqlserver-to-csql-pgsql/work-with-conversion-workspaces.md.txt#apply-to-dest).

To migrate SQL Server tables without primary keys, do the following:

1. [Convert all your schema and apply it to the destination database](https://docs.cloud.google.com/database-migration/docs/sqlserver-to-csql-pgsql/convert-sql.md.txt).
2. Connect to your destination Cloud SQL instance with a SQL client. You can use the following methods:
   - [`psql` client](https://docs.cloud.google.com/sql/docs/postgres/connect-admin-ip.md.txt). You can use this method to connect to your instance private IP, but it might require that you create a Compute Engine virtual machine.
   - [`gcloud sql connect`](https://docs.cloud.google.com/sdk/gcloud/reference/sql/connect) command. This command works only for Cloud SQL instances that have a public IP address enabled.
3. Create the missing primary key constraints for your tables. For more information about primary keys, see [Primary Keys](https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-PRIMARY-KEYS) in the PostgreSQL documentation.

   You can also expand the following sections to see sample SQL commands:

   #### Create primary keys using existing columns

   Your table might already have a logical primary key based on a
   column or a combination of columns. For example, there might be
   columns with a unique constraint or index configured. Use these
   columns to generate a new primary key for tables in your source
   database. For example:

   ```sql
   ALTER TABLE TABLE_NAME
   ADD PRIMARY KEY (COLUMN_NAME);
   ```

   <br />

   #### Create a primary key using all columns

   If you don't have a pre-existing constraint that could serve as a
   primary key, create primary keys using all columns of the table. Make
   sure that you don't exceed the maximum length of the primary key
   allowed by your PostgreSQL instance. For example:

   ```sql
   ALTER TABLE TABLE_NAME
   ADD PRIMARY KEY (COLUMN_NAME_1, COLUMN_NAME_2, COLUMN_NAME_3, ...);
   ```

   When creating a composite primary key like this, you need to explicitly
   list all column names you want to use. It's not possible to use a statement
   to retrieve all column names for this purpose.

## What's next

- Once all your converted tables have primary key constraints, you can
  proceed with your migration and
  [create a migration job](https://docs.cloud.google.com/database-migration/docs/sqlserver-to-csql-pgsql/create-migration-job.md.txt).

- To get a complete, step-by-step migration walkthrough, see
  [SQL Server to Cloud SQL for PostgreSQL migration guide](https://docs.cloud.google.com/database-migration/docs/sqlserver-to-csql-pgsql/guide.md.txt).