skip to Main Content

I’m a beginner and have no idea what to do!
This is clearly not working
I’m using phpmyadmin importing code manually by hand from postgresql


    CREATE TABLE IF NOT EXISTS CUSTOMER (
     CUSTID              NUMERIC(6) NOT NULL,
     NAME                CHAR (45),
     ADDRESS             CHAR (40),
     CITY                CHAR (30),
     STATE               CHAR (2),
     ZIP                 CHAR (9),
     AREA                NUMERIC(3),
     PHONE               CHAR (9),
     REPID               NUMERIC(4) NOT NULL,
     CREDITLIMIT         NUMERIC(9,2),
     COMMENTS            TEXT,
     CONSTRAINT CUSTOMER_PRIMARY_KEY PRIMARY KEY (CUSTID));
     USE CUSTOMERS
     CONSTRAINT CUSTID_ZERO CHECK (CUSTID > 0)

SQL query:

USE CUSTOMERS
CONSTRAINT CUSTID_ZERO CHECK (CUSTID > 0)

MySQL said: Documentation

1064 – You have an error in your SQL syntax; check the manual that corresponds to your MariaDB >server version for the right syntax to use near ‘CONSTRAINT CUSTID_ZERO CHECK (CUSTID > 0)’ at line >2

2

Answers


  1. you don’t need the last line,

    CONSTRAINT CUSTID_ZERO CHECK (CUSTID > 0)
    

    Because when you declared CUSTID you already mentioned NOT NULL

    Login or Signup to reply.
  2. Changê you query to

    ALTER TABLE CUSTOMER 
    ADD CONSTRAINT CUSTID_ZERO CHECK (CUSTID > 0)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search