Wednesday, November 14, 2012

Re: mysql sakila db install

Quick q: have you already created the city table? I was able to create the table without that constraint.

sql> CREATE TABLE address (
->   address_id SMALLINT NOT NULL AUTO_INCREMENT,
->   address VARCHAR(50) NOT NULL,
->   address2 VARCHAR(50) DEFAULT NULL,
->   district VARCHAR(20) NOT NULL,
->   city_id SMALLINT UNSIGNED NOT NULL,
->   postal_code VARCHAR(10) DEFAULT NULL,
->   phone VARCHAR(20) NOT NULL,
->   last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
->   PRIMARY KEY  (address_id),
->   KEY idx_fk_city_id (city_id)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
0 row(s) affected.
sql>

-- Razvan ME


On Wed, Nov 14, 2012 at 7:46 AM, Dinesh Mistry <dinesh.mistry@j3dsolutions.com> wrote:
Thanks in advance for any assistance.

I am brand new to cloud SQL. To get started I want to install sakila db (from mysql site) which I have installed in other offline mysql instances w/o problem. 

When I do the same in Cloud SQL, I get this?

Error 1064: 
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE address ( address_id SMALLINT NOT NULL AUTO_INCREMENT, address ' at line 18
 

Below SQL tried to execute.

CREATE TABLE address (
  address_id SMALLINT NOT NULL AUTO_INCREMENT,
  address VARCHAR(50) NOT NULL,
  address2 VARCHAR(50) DEFAULT NULL,
  district VARCHAR(20) NOT NULL,
  city_id SMALLINT UNSIGNED NOT NULL,
  postal_code VARCHAR(10) DEFAULT NULL,
  phone VARCHAR(20) NOT NULL,
  last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY  (address_id),
  KEY idx_fk_city_id (city_id),
  CONSTRAINT `fk_address_city` FOREIGN KEY (city_id) REFERENCES city (city_id) ON DELETE RESTRICT ON UPDATE CASCADE
)ENGINE=InnoDB DEFAULT CHARSET=utf8;

No comments:

Post a Comment