Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register


0
(click on this box to dismiss)

How to ALTER TABLE and SET DEFAULT in CUBRID?

I have the following table already created in my database.

CREATE TABLE "tbl_users"(
     "id" integer AUTO_INCREMENT,
     "email" character varying(100) NOT NULL UNIQUE,
     "join_date" integer NOT NULL,
     CONSTRAINT pk_tbl_users_id PRIMARY KEY("id")
);

I want to alter the table schema and set the default value for join_date column to be the current timestamp in UNIX time. I tried the following SQL, but I keep getting "Syntax: syntax error, unexpected IdName" error.

ALTER  tbl_users ALTER  join_date SET DEFAULT UNIX_TIMESTAMP(CURRENT_TIMESTAMP());

How should I do?

link comment (0) accepted answer
asked last year
eye
91
1 Answer
1
Overall your ALTER... the syntax is correct. However, the part which says UNIX_TIMESTAMP() is not valid. In CUBRID, the default value has to be a constant value, not an expression. In this case the current timestamp calculated by this functions is not constant. Therefore the entire query becomes invalid.
link comment (0)
answered last year
dba
558




You are either using a very old browser or a browser that is not supported.
In order to browse cubrid.org you need to have one of the following browsers:



Internet Explorer: Mozilla Firefox: Google Chrome: