< Back

Import-GcSqlInstance

Mon Jan 13, 2020 11:23 pm

NAME Import-GcSqlInstance



SYNOPSIS

Imports data into a Cloud SQL instance from a MySQL dump or CSV file stored either in a Google Cloud Storage

bucket or on your local machine.





SYNTAX

Import-GcSqlInstance [-Project <string>] [-Instance] <string> [-ImportFilePath] <string> [-Database] <string>

[-DestinationTable] <string> [[-Column] <string[]>] [<CommonParameters>]





DESCRIPTION

Imports data into a Cloud SQL instance from a MySQL dump or CSV file stored either in a Google Cloud Storage

bucket or on your local machine. Only one database may be imported from a MySQL file, and only one table may be

imported from a CSV file.



WARNING: Standard charging rates apply if a file is imported from your local machine. A Google Cloud Storage

bucket will be set up, uploaded to, and imported from during the import process. It is deleted after the upload

and/or import process fails or is completed





PARAMETERS

-Project <string>

Name of the project. Defaults to the active cloud sdk config for properties if not specified.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Instance <string>

The name of the instance to have data exported to.



Required? true

Position? 0

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ImportFilePath <string>

The path to the file where the import file is stored. A Google Cloud Storage path is in the form

"gs://bucketName/fileName".



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Database <string>

The database inside of the Instance (for example, "guestbook" or "orders") to which the import is made. It

must already exist.



If filetype is SQL and no database is specified, it is assumed that the database is specified in the file to

be imported. The filetype of the file is assumed to be the corresponding parameter set.



Required? true

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-DestinationTable <string>

The table to which CSV data is imported. Must be specified for a CSV file.



Required? true

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Column <string[]>

The columns of the CSV data to import. If not specified, all columns are imported.



Required? false

Position? 4

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



---------- EXAMPLE 1 ----------



PS C:\\> Import-GcSqlInstance "myInstance" "gs://bucket/file" "myData"



Imports the MySQL dump file at "gs://bucket/file" into the already existing database "myData" in the instance

"myInstance".

---------- EXAMPLE 2 ----------



PS C:\\> Import-GcSqlInstance "myInstance" "gs://bucket/file.csv" "myData" "myTable"



Imports the CSV file at "gs://bucket/file.csv" into the table "myTable" in the already existing database "myData"

in the instance "myInstance".

---------- EXAMPLE 3 ----------



PS C:\\> Import-GcSqlInstance "myInstance" "C:\\Users\\Bob\\file.csv" "myData" "myTable"



Imports the CSV file at "C:\\Users\\Bob\\file.csv" into the table "myTable" in the already existing database "myData"

in the instance "myInstance".



RELATED LINKS

[How-To: Importing and Exporting] (https://cloud.google.com/tools/powershe ... ort-export)

[Overview of Importing and Exporting] (https://cloud.google.com/sql/docs/import-export/)