Ora2Pg 구성을 만들고 작업공간을 만든 후 생성된 코드를 대상 데이터베이스에 직접 적용해야 합니다.
기본 키가 없는 테이블을 마이그레이션합니다.
Database Migration Service는 기본 키가 있는 테이블만 마이그레이션합니다.
소스 데이터베이스에 기본 키가 없는 테이블이 포함된 경우 변환된 스키마를 적용한 후 대상 데이터베이스의 변환된 테이블에서 기본 키 또는 고유 제약 조건을 수동으로 만들어야 합니다. 자세한 내용은 다음 섹션을 펼치세요.
대상 데이터베이스에 기본 키 제약 조건 추가
기본 키가 없는 Oracle 테이블을 마이그레이션하려면 다음 단계를 따르세요.
SQL 클라이언트로 대상 Cloud SQL 인스턴스에 연결합니다. 다음 방법을 사용할 수 있습니다.
psql client. 이 방법을 사용하여 인스턴스 비공개 IP에 연결할 수 있지만 Compute Engine 가상 머신을 만들어야 할 수 있습니다.
이와 같이 복합 기본 키를 만들 때는 사용할 모든 열 이름을 명시적으로 나열해야 합니다. 이 목적으로 문을 사용하여 모든 열 이름을 가져올 수는 없습니다.
ROWID 의사 열을 사용하여 고유 제약 조건 만들기
Oracle 데이터베이스는 ROWID 유사 열을 사용하여 테이블의 각 행 위치를 저장합니다. 기본 키가 없는 Oracle 테이블을 마이그레이션하려면 대상 PostgreSQL 데이터베이스에 ROWID 열을 추가하면 됩니다. Database Migration Service는 소스 Oracle ROWID 유사 열의 해당 숫자 값으로 열을 채웁니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-18(UTC)"],[],[],null,["# About legacy conversion workspaces\n\nLegacy conversion workspaces are an older, more limited type of conversion\nworkspaces. Legacy conversion workspaces don't support Gemini-enhanced\nconversion features or the interactive SQL editor. You can only use them to convert your\nsource schema with the Ora2Pg migration tool.\n| **Important:** Database Migration Service supports Ora2Pg versions `21.1` - `23.2`.\n\nWe don't recommend using the legacy type of conversion workspaces for your\nmigrations as they present multiple other limitations to the conversion\nworkflow:\n\nUse legacy conversion workspaces\n--------------------------------\n\nIf your scenario requires the use of legacy conversion workspaces,\nmodify the migration process with the following actions:\n\n1. Write an Ora2Pg configuration file.\n\n Refer to the\n [Ora2Pg documentation](https://ora2pg.darold.net/documentation.html#CONFIGURATION) for guidance on how to use\n the Ora2Pg conversion tool. Expand the following sections for the full\n list of directives supported in Database Migration Service. \n\n #### Ora2Pg configuration supported in Database Migration Service\n\n Database Migration Service supports the following configuration items for Ora2Pg files:\n - `BOOLEAN_VALUES`\n - `DATA_TYPE`\n - `DEFAULT_NUMERIC`\n - `ENABLE_MICROSECOND`\n - `EXPORT_SCHEMA`\n - `MODIFY_STRUCT`\n - `MODIFY_TYPE`\n - `PG_INTEGER_TYPE`\n - `PG_NUMERIC_TYPE`\n - `PG_SCHEMA`\n - `PRESERVE_CASE`\n - `REPLACE_AS_BOOLEAN`\n - `REPLACE_COLS`\n - `REPLACE_TABLES`\n - `REPLACE_ZERO_DATE`\n - `SCHEMA`\n\n Database Migration Service uses connection profiles to define\n connectivity details, so you don't need to define the following information\n in your Or2Pg configuration file:\n - `ORACLE_DSN`\n - `ORACLE_HOME`\n - `ORACLE_PWD`\n - `ORACLE_USER`\n - `PG_DSN`\n - `PG_PWD`\n - `PG_USER`\n\n Additionally, Database Migration Service doesn't use the `WHERE`\n configuration directive to limit the records to migrate.\n2. [Create a legacy conversion workspace, and upload the Ora2Pg file to convert\n your schema](/database-migration/docs/oracle-to-postgresql/create-conversion-workspace#legacy-ws).\n3. Manually apply converted schema to the destination database.\n\n\n After you create the Ora2Pg configuration and create the workspace,\n you must apply the generated code by yourself directly on the destination\n database.\n | **Important:** With legacy conversion workspaces, you can't test the schema before you migrate. If you encounter any issues when you apply the converted schema, you need to clear the faulty schema from the destination database, adjust your Ora2Pg file, and re-create the legacy conversion workspace with the Ora2Pg file.\n4. Migrate tables without primary keys.\n\n\n Database Migration Service migrates only tables that have primary keys.\n If your source database includes tables that don't have primary keys,\n you need to manually create primary keys or unique constraints in the\n converted tables in the destination database after you\n apply the converted schema. Expand the following section for more details. \n\n #### Add primary key constraints in the destination database\n\n To migrate Oracle tables without primary keys, do the following:\n 1. Connect to your destination Cloud SQL instance with a SQL client. You can use the following methods:\n - [`psql` client](/sql/docs/postgres/connect-admin-ip). You can use this method to connect to your instance private IP, but it might require that you create a Compute Engine virtual machine.\n - [`gcloud sql connect`](/sdk/gcloud/reference/sql/connect) command. This command works only for Cloud SQL instances that have a public IP address enabled.\n 2. 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.\n\n You can also expand the following sections to see sample SQL commands: \n\n #### Create primary keys using existing columns\n\n Your table might already have a logical primary key based on a\n column or a combination of columns. For example, there might be\n columns with a unique constraint or index configured. Use these\n columns to generate a new primary key for tables in your source\n database. For example: \n\n ```sql\n ALTER TABLE TABLE_NAME\n ADD PRIMARY KEY (COLUMN_NAME);\n ```\n\n \u003cbr /\u003e\n\n #### Create a primary key using all columns\n\n If you don't have a pre-existing constraint that could serve as a\n primary key, create primary keys using all columns of the table. Make\n sure that you don't exceed the maximum length of the primary key\n allowed by your PostgreSQL instance. For example: \n\n ```sql\n ALTER TABLE TABLE_NAME\n ADD PRIMARY KEY (COLUMN_NAME_1, COLUMN_NAME_2, COLUMN_NAME_3, ...);\n ```\n\n When creating a composite primary key like this, you need to explicitly\n list all column names you want to use. It's not possible to use a statement\n to retrieve all column names for this purpose. \n\n #### Create a unique constraint with the `ROWID` pseudocolumn\n\n Oracle databases use the\n [`ROWID` pseudocolumn](https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/ROWID-Pseudocolumn.html) to store\n the location of each row in a table. To migrate Oracle tables\n that don't have primary keys, you can add a `ROWID`\n column in the destination PostgreSQL database. Database Migration Service\n populates the column with the corresponding numeric values from\n the source Oracle `ROWID` pseudocolumn.\n\n To add the column and to set it as the primary key, run the following: \n\n ```sql\n ALTER TABLE TABLE_NAME ADD COLUMN rowid numeric(33,0) NOT NULL;\n CREATE SEQUENCE TABLE_NAME_rowid_seq INCREMENT BY -1 START WITH -1 OWNED BY TABLE_NAME.rowid;\n ALTER TABLE TABLE_NAME ALTER COLUMN rowid SET DEFAULT nextval('\u003cvar translate=\"no\"\u003eTABLE_NAME\u003c/var\u003e_rowid_seq');\n ALTER TABLE TABLE_NAME ADD CONSTRAINT CONSTRAINT_DISPLAY_NAME PRIMARY KEY (rowid);\n ```\n\nWhat's next\n-----------\n\nAfter you perform the conversion workflow with the legacy workspace,\nyou can proceed with the standard migration procedures. See\n[Create a migration job](/database-migration/docs/oracle-to-postgresql/create-migration-job)."]]