I connected to a Google Cloud SQL database from eclipse using Data Source explorer. But when I generate DDL of that database using its option Generate DDL
, I can't get the AUTO_INCREMENT
in my script but get the corresponding primary key.
How would i go about getting the AUTO_INCREMENT
in my script?
In the Google Cloud console, go to the Cloud SQL Instances page. To open the Overview page of an instance, click the instance name. Select Connections from the SQL navigation menu. In the Authorized networks section, click Add network and enter the IP address of the machine where the client is installed.
Cloud SQL is a fully-managed database service that helps you set up, maintain, manage, and administer your relational databases on Google Cloud Platform. You can use Cloud SQL with MySQL, PostgreSQL, or SQL Server.
Google Cloud SQL is a managed database service that allows you to run Microsoft SQL Server, MySQL, and PostgreSQL on Google Cloud. The service provides replication, automated backups, and failover to ensure high-availability and resilience.
While this is not directly answering the question, I believe it will provide a solution to the root goal: Extracting the DDL.
Assumption: The following is a shell script, so an appropriate environment (OS X, Linux, cygwin) is required
Steps:
Create the following custom script in the same directory as the google_sql.sh:
GOOGLE_CLOUD_SQL_INSTANCE=test:test echo "SELECT CONCAT('SELECT CONCAT(\"SHOW CREATE TABLE ',schema_name,'.\",table_name,\";\") \"select \\\\\"use ',schema_name,';\\\\\";\" FROM information_schema.tables WHERE table_schema = \"',schema_name,'\";') 'use information_schema;' FROM SCHEMATA WHERE schema_name NOT IN ('information_schema','mysql','performance_schema');" >> $$.1.get_schema.sql ./google_sql.sh $GOOGLE_CLOUD_SQL_INSTANCE information_schema < $$.1.get_schema.sql > $$.2.show_create.sql ./google_sql.sh $GOOGLE_CLOUD_SQL_INSTANCE information_schema < $$.2.show_create.sql > $$.3.sql.out ./google_sql.sh $GOOGLE_CLOUD_SQL_INSTANCE information_schema < $$.3.sql.out > $$.4.create.raw awk -F" " '/Table Create Table/{print "";} /CREATE/{sub(/^..*CREATE TABLE/,"CREATE TABLE");print $0} $1 == "" {print $0} /^\)/{print $0";"} /^use/{print $0}' $$.4.create.raw > $GOOGLE_CLOUD_SQL_INSTANCE.ddl.sql rm $$.*
Replace "test:test" in the script with your Google Cloud instance identifier
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With