Home > database >  PostgreSQL create table is how to carry on the limit of characters or the value of the integer
PostgreSQL create table is how to carry on the limit of characters or the value of the integer

Time:10-06

PostgreSQL how to create tables for a character or to restrict
the value of the integer
Specific issues are as follows:
Create a CUSTOMER table
Requirements
1. The SERVICE (string) values only for "Electricity" or "Gas"
2. The PERIOD (integer) value can only be for 1 to 6 in a
3. The value of EMAIL (string) must contain '@'

Consult bosses see below write right:
1. The SERVICE VARCHAR (12) CHECK (SERVICE IN (" Electricity ", "Gas"))
If any wrong words must use enum
2. The PERIOD INT CHECK (PERIOD IN (6))
If the if change to 1-999 can't go on this way
3. EMAIL VARCHAR (60) CHECK (EMAIL like '% @ %')
  • Related