简体   繁体   中英

How to alter a table and add in a date column which doesn't allow dates before a certain date in sql?

I need an sql query to alter a table to add in a date column, which is the part I know how to do. What I don't know how to do is specify that the dates in the column need to be after a certain date.

My latest attempt:

ALTER TABLE <table name>
ADD constraint <constraint name>
CHECK (<column name>(date, 'YYYY-MM-DD') >= '2000-01-01');

I'm using pgadmin4.

这个怎么样?

ALTER TABLE t ADD constraint chk_t_col CHECK (col >= '2000-01-01');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM