简体   繁体   中英

Limit variable in SQL table

How can I limit a variable in the creation of a table in sql? For example, I want the number to be lower than 1000, so I tried:

CREATE TABLE DATA (
cost int(<1000) NOT NULL
)

You want a check constraint:

create table data (
    cost int not null,
    check (cost < 1000)
)

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