Skip to main content
Rollback to Revision 1
Source Link
Bugs
  • 4.5k
  • 9
  • 34
  • 41

I am new to SQL and am attempted to create a table, then alter the table to add some constraints with ALTER and finally insert 2 employees, one managing the other. I have been getting this error in pgAdmin4 "ERROR: syntax error at or near ""INSERT" If anyone could let me know any other obvious issues in my code that would be great

Here is the table:

CREATE TABLE employee ( 
    emp_id     integer NOT NULL, 
    first_name varchar(15) NOT NULL, 
    last_name  varchar(15) NOT NULL, 
    manager    integer 
); 

And the altering:

ALTER TABLE employee ADD CONSTRAINT unique_emp_id UNIQUE (emp_id);  

ALTER TABLE employee ADD FOREIGN KEY (manager) REFERENCES emp_id;

ALTER TABLE employee ADD CHECK (emp_id != manager)

INSERT INTO employee VALUES
  (1, 'Tom', 'Jones', 2);

INSERT INTO employee (emp_id, first_name, last_name)
  VALUES  (2, 'Dave', 'Smith');

I am new to SQL and am attempted to create a table, then alter the table to add some constraints with ALTER and finally insert 2 employees, one managing the other. I have been getting this error in pgAdmin4 "ERROR: syntax error at or near "

I am new to SQL and am attempted to create a table, then alter the table to add some constraints with ALTER and finally insert 2 employees, one managing the other. I have been getting this error in pgAdmin4 "ERROR: syntax error at or near "INSERT" If anyone could let me know any other obvious issues in my code that would be great

Here is the table:

CREATE TABLE employee ( 
    emp_id     integer NOT NULL, 
    first_name varchar(15) NOT NULL, 
    last_name  varchar(15) NOT NULL, 
    manager    integer 
); 

And the altering:

ALTER TABLE employee ADD CONSTRAINT unique_emp_id UNIQUE (emp_id);  

ALTER TABLE employee ADD FOREIGN KEY (manager) REFERENCES emp_id;

ALTER TABLE employee ADD CHECK (emp_id != manager)

INSERT INTO employee VALUES
  (1, 'Tom', 'Jones', 2);

INSERT INTO employee (emp_id, first_name, last_name)
  VALUES  (2, 'Dave', 'Smith');
deleted 715 characters in body
Source Link

I am new to SQL and am attempted to create a table, then alter the table to add some constraints with ALTER and finally insert 2 employees, one managing the other. I have been getting this error in pgAdmin4 "ERROR: syntax error at or near "INSERT" If anyone could let me know any other obvious issues in my code that would be great

Here is the table:

CREATE TABLE employee ( 
    emp_id     integer NOT NULL, 
    first_name varchar(15) NOT NULL, 
    last_name  varchar(15) NOT NULL, 
    manager    integer 
); 

And the altering:"

ALTER TABLE employee ADD CONSTRAINT unique_emp_id UNIQUE (emp_id);  

ALTER TABLE employee ADD FOREIGN KEY (manager) REFERENCES emp_id;

ALTER TABLE employee ADD CHECK (emp_id != manager)

INSERT INTO employee VALUES
  (1, 'Tom', 'Jones', 2);

INSERT INTO employee (emp_id, first_name, last_name)
  VALUES  (2, 'Dave', 'Smith');

I am new to SQL and am attempted to create a table, then alter the table to add some constraints with ALTER and finally insert 2 employees, one managing the other. I have been getting this error in pgAdmin4 "ERROR: syntax error at or near "INSERT" If anyone could let me know any other obvious issues in my code that would be great

Here is the table:

CREATE TABLE employee ( 
    emp_id     integer NOT NULL, 
    first_name varchar(15) NOT NULL, 
    last_name  varchar(15) NOT NULL, 
    manager    integer 
); 

And the altering:

ALTER TABLE employee ADD CONSTRAINT unique_emp_id UNIQUE (emp_id);  

ALTER TABLE employee ADD FOREIGN KEY (manager) REFERENCES emp_id;

ALTER TABLE employee ADD CHECK (emp_id != manager)

INSERT INTO employee VALUES
  (1, 'Tom', 'Jones', 2);

INSERT INTO employee (emp_id, first_name, last_name)
  VALUES  (2, 'Dave', 'Smith');

I am new to SQL and am attempted to create a table, then alter the table to add some constraints with ALTER and finally insert 2 employees, one managing the other. I have been getting this error in pgAdmin4 "ERROR: syntax error at or near "

Source Link

"ERROR: syntax error at or near "INSERT" " PostgreSQL error

I am new to SQL and am attempted to create a table, then alter the table to add some constraints with ALTER and finally insert 2 employees, one managing the other. I have been getting this error in pgAdmin4 "ERROR: syntax error at or near "INSERT" If anyone could let me know any other obvious issues in my code that would be great

Here is the table:

CREATE TABLE employee ( 
    emp_id     integer NOT NULL, 
    first_name varchar(15) NOT NULL, 
    last_name  varchar(15) NOT NULL, 
    manager    integer 
); 

And the altering:

ALTER TABLE employee ADD CONSTRAINT unique_emp_id UNIQUE (emp_id);  

ALTER TABLE employee ADD FOREIGN KEY (manager) REFERENCES emp_id;

ALTER TABLE employee ADD CHECK (emp_id != manager)

INSERT INTO employee VALUES
  (1, 'Tom', 'Jones', 2);

INSERT INTO employee (emp_id, first_name, last_name)
  VALUES  (2, 'Dave', 'Smith');