4

Am really new to Mysql. Is it possible to do something like the following in some way? Mysql throws a syntax error as expected but is there something that I should change that would make it work?

CREATE TABLE tracksession(ID INT NOT NULL AUTO_INCREMENT,
             user_id INT DEFAULT NULL,
             leave_mode ENUM('loggedout', 'timedout') DEFAULT NULL,
             login TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
             logout TIMESTAMP DEFAULT ADDDATE(CURRENT_TIMESTAMP, INTERVAL 20 MINUTE),
             PRIMARY KEY(ID));

Thanks in advance.

1 Answer 1

6

Nope you cannot do this

DEFAULT ADDDATE(CURRENT_TIMESTAMP, INTERVAL 20 MINUTE),

explanation from the manual :

The DEFAULT value clause in a data type specification indicates a default value for a column. With one exception, the default value must be a constant; it cannot be a function or an expression.

Must be a constant not a function ...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.