1
CREATE TABLE plan 
 ( 
 id VARCHAR(30) NOT NULL, 
 name VARCHAR(20), 
 amount INT, 
 interval INT, 
 currency CHAR(3), 
 object VARCHAR(20), 
 livemode BOOLEAN, 
 interval_count INT, 
 trial_period_days INT, 
 created TIMESTAMP, 
 updated TIMESTAMP, 
 deleted TIMESTAMP, 
 PRIMARY KEY (id) 
 ); 

Produces

'ERROR 1064 (42000): 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 'interval INT, 
 currency CHAR(3), 
 object ' at line 6'

Doesn't work. However if the 'l' at the end of 'interval' is removed. It works.

CREATE TABLE plan 
 ( 
 id VARCHAR(30) NOT NULL, 
 name VARCHAR(20), 
 amount INT, 
 interva INT, 
 currency CHAR(3), 
 object VARCHAR(20), 
 livemode BOOLEAN, 
 interval_count INT, 
 trial_period_days INT, 
 created TIMESTAMP, 
 updated TIMESTAMP, 
 deleted TIMESTAMP, 
 PRIMARY KEY (id) 
 ); 

I don't understand if this is a problem with attempting to use 'interval' and 'interval_count'. What's going on here.

asked Feb 12, 2013 at 4:02

1 Answer 1

3

The word "interval" is a reserved word. You can still use it if you quote it correctly.

See the MySQL Manual for a list of the reserved words and how to use them. In fact, "interval" is the first example in the link provided:

mysql> CREATE TABLE interval (begin INT, end INT);
ERROR 1064 (42000): You have an error in your SQL syntax ...
near 'interval (begin INT, end INT)'
mysql> CREATE TABLE `interval` (begin INT, end INT);
Query OK, 0 rows affected (0.01 sec)
answered Feb 12, 2013 at 4:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.