0

I am trying to create my first SQL table and I am getting a syntax error and cannot figure out why. Here is my code:

create table ps 
(
  USER VARCHAR(20),
  PID INT(10),
  %CPU DECIMAL(4),
  %MEM DECIMAL(4),
  VSZ INT(10),
  RSS INT(10),
  TTY VARCHAR(10),
  STAT VARCHAR(5),
  START VARCHAR(20),
  TIME VARCHAR(20),
  COMMAND VARCHAR(20)
);
3
  • The % in %CPU and %MEM looks suspicious. Did you try without the % yet? You can always delete the table and try again. Commented Nov 11, 2015 at 16:33
  • When asking about a specific error, you must always include the actual error you're talking about. Commented Nov 11, 2015 at 16:40
  • 1
    What rdbms are you using, and what error are you getting? Commented Jun 12, 2016 at 21:16

1 Answer 1

1

As Sarah suggested, you are setting strange names to your columns, remove %

create table ps 
(
  USER VARCHAR(20),
  PID INT(10),
  PERC_CPU DECIMAL(4),
  PERC_MEM DECIMAL(4),
  VSZ INT(10),
  RSS INT(10),
  TTY VARCHAR(10),
  STAT VARCHAR(5),
  START VARCHAR(20),
  TIME VARCHAR(20),
  COMMAND VARCHAR(20)
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.