CloudSQL for PostgreSQL


Connect to your Cloud SQL instance (instance ID: myinstance) by running:

gcloud sql connect myinstance --user=postgres

Insert sample data into the postgres database:

CREATE TABLE guestbook (guestName VARCHAR(255), content VARCHAR(255),
                        entryID SERIAL PRIMARY KEY);
INSERT INTO guestbook (guestName, content) values ('first guest', 'I got here!');
INSERT INTO guestbook (guestName, content) values ('second guest', 'Me too!');

Retrieve the data:

SELECT * FROM guestbook;

Postgres Cloud SQL has a default database ‘postgres’