0

I am trying to create in postgresSQL 9.3 tables

CREATE TABLE Customer
(
  cid INT,
  name VARCHAR(32),
);
CREATE TABLE Product
(   
 producno INT,
 name VARCHAR,
 );
CREATE TABLE Order
 (
  oderid INT,
  shipdate DATE,
  cid INT,
 );
CREATE TABLE Ordered
(
 orderid INT,
 prodno INT,
 );

But I get an syntax error on line 5 ')'

SQL Status:42601 So I have already looked in PostgreSQL Error Codes so it says only that it is a syntax error But if I try it with other querys from the internet it works but trying to create my own I get an error

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
ThePom
  • 95
  • 3
  • 13

2 Answers2

2

Remove comma from all the last fields

CREATE TABLE Customer
(
  cid INT,
  name VARCHAR(32),
);

to

CREATE TABLE Customer
(
  cid INT,
  name VARCHAR(32)
);

And so on for others.

Abhik Chakraborty
  • 44,654
  • 6
  • 52
  • 63
  • could you maybe help me with a relational algebra? – ThePom May 21 '14 at 20:49
  • ok post that and you have tagged the question with mysql , postgreysql so make sure to specify which database you are trying to do the operation. – Abhik Chakraborty May 21 '14 at 20:55
  • I have now SQL and want to create the RA here http://stackoverflow.com/questions/23781004/selecting-from-three-relation-with-relational-algebra and http://stackoverflow.com/questions/23791505/date-in-sql-and-relation-algebra-is-null and I am not sure if I've done it right – ThePom May 21 '14 at 20:59
  • have you checked the answer from Michael Green that does exactly the thing you wanted. Now relational algebra is a representation of entity relations.And queries are basically in the form of SQL not relational expression.You may check http://www.cs.duke.edu/~junyang/ra/ this which converts a relational algebra to SQL – Abhik Chakraborty May 21 '14 at 21:11
  • you may check this http://www.go4expert.com/articles/relational-algebra-operations-sql-t21166/ – Abhik Chakraborty May 21 '14 at 21:15
  • Yeah that the SQL query but I am trying to create the in relational algebra so I think it should look like πE.eid(σC.Name='Obama'(Customer)))⋈Resp_for⋈Employee) but I am not sure if that is correct – ThePom May 21 '14 at 21:15
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/54154/discussion-between-kate-and-abhik-chakraborty). – ThePom May 21 '14 at 21:22
  • ok `σC.Name='Obama' = single relation` `σC.Name='Obama'(Customer)))⋈Resp_fo = single rel on Resp_fo` and so on, it looks correct. And rest is just association in the expression on eid where eid is the joining key. So I would say it looks good. But an expert can give you more details since its been a decade I have not done this and what I learned during my masters with that trying to help you out :) – Abhik Chakraborty May 21 '14 at 21:24
0

If column start with any number some time pg gives 42601 org.postgresql.util.PSQLException: ERROR: syntax error at or near "1" Position: 107

So pelase check table create sql before execution