Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

About Google Cloud SQL Instance "Import" functionality

Hello Google, I am a new user and would like to know what are some properties of using the "Import" function for importing into MySQL on gcloud. Mainly when I use the "Import" option on the platform:

  1. When I am doing it on a existed table and database, would the old data (with different primary key) be overwritten? 
  2. Would the old data (with the same primary key) be modified?
  3. Is there any other way to do the "Import"?

Thank you for your help, as I cannot find the answers in other places.

Screenshot 2022-10-06 155952.png

Solved Solved
0 3 581
1 ACCEPTED SOLUTION

Hello infomaccrm

To answer your questions regarding the primary key:  

Include PRIMARY KEY in the ADD clause to add a primary key to a table definition. The primary key is a unique index that does not include null values. When you specify a primary key, Zen creates a unique index with the specified attributes on the defined group of columns.

Because a table can have only one primary key, you cannot add a primary key to a table that already has a primary key defined. To change the primary key of a table, delete the existing key using a DROP clause in an ALTER TABLE statement and add the new primary key.

Find below some links that can help you starting with MySQL:

Use the same SQL mode for import and export.

Don't use Cloud Storage Requester Pays buckets.

Minimize the performance impact of exports.

Use the correct flags when you create a SQL dump file.

Compress data to reduce cost.

Reduce long-running import and export processes.

Use InnoDB.

MySQL import and migration jobs containing metadata with DEFINER clause.

Verify the imported database.

Additionally, here is a stackoverflow answer that can help you.  

Are you following any documentation or guide for what you are trying to achieve?

View solution in original post

3 REPLIES 3

Please refer to the answer provided by Andre_Fiesco

Hello infomaccrm

To answer your questions regarding the primary key:  

Include PRIMARY KEY in the ADD clause to add a primary key to a table definition. The primary key is a unique index that does not include null values. When you specify a primary key, Zen creates a unique index with the specified attributes on the defined group of columns.

Because a table can have only one primary key, you cannot add a primary key to a table that already has a primary key defined. To change the primary key of a table, delete the existing key using a DROP clause in an ALTER TABLE statement and add the new primary key.

Find below some links that can help you starting with MySQL:

Use the same SQL mode for import and export.

Don't use Cloud Storage Requester Pays buckets.

Minimize the performance impact of exports.

Use the correct flags when you create a SQL dump file.

Compress data to reduce cost.

Reduce long-running import and export processes.

Use InnoDB.

MySQL import and migration jobs containing metadata with DEFINER clause.

Verify the imported database.

Additionally, here is a stackoverflow answer that can help you.  

Are you following any documentation or guide for what you are trying to achieve?

Thank you so much for your clarification. This really helps me on the work.