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?
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.
asked last year
viewed 616 times