Postgres Create Table Syntax Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn error syntax error at or near postgresql more about Stack Overflow the company Business Learn more about hiring developers or
Syntax Error At Or Near Create Postgres
posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community error: syntax error at or near "create" Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Postgres drop table syntax error up vote 7 down vote
Postgres Create Table Example
favorite Postgres 9.3.2 on heroku. Pretty sure I'm just being an idiot, but I can't seem to figure out why my syntax is wrong. db=> \dt List of relations Schema | Name | Type | Owner --------+------------+-------+---------------- public | device | table | admin public | post | table | admin public | user | table | admin (3 rows) // why does this fail? db=> drop table postgres create table if not exists user; ERROR: syntax error at or near "user" LINE 1: drop table user; // does the right thing db=> drop table error; ERROR: table "error" does not exist sql postgresql heroku share|improve this question asked Jan 10 '14 at 18:18 Derek 3,3551054103 add a comment| 1 Answer 1 active oldest votes up vote 12 down vote accepted User is a reserved keyword in Postgres. You'll have to put it in quotes if you want to refer to an actual table named user: DROP TABLE "user"; Probably best to stay away from using reserved keywords as table names if you can help it. It usually ends up creating weird problems down the road. Users might be a better name for a table. share|improve this answer answered Jan 10 '14 at 18:19 Mike Christensen 44.5k18126230 Thanks. Did not know that. Will accept in 12 minutes. –Derek Jan 10 '14 at 18:21 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the pri
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of
Postgresql Drop Table If Exists
this site About Us Learn more about Stack Overflow the company Business
Postgresql References
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask foreign key postgres Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign http://stackoverflow.com/questions/21051521/postgres-drop-table-syntax-error up PostgreSQL: syntax error while creating a table in PostgreSql up vote 0 down vote favorite I'm new to PostgreSQL, just follow the documentation at https://www.postgresql.org/docs/9.6/static/tutorial-table.html. I'm trying to create a table. This is the output: postgres=# $ psql mydb postgres=# CREATE TABLE weather ( city varchar(80), temp_lo int, temp_hi int, prcp real, date date ); ERROR: syntax error at or near "$" http://stackoverflow.com/questions/39496139/postgresql-syntax-error-while-creating-a-table-in-postgresql LINE 1: $ psql mydb ^ Could you tell me please what's wrong in syntax? Thanks in advance. postgresql share|improve this question asked Sep 14 at 17:11 Eugenia Ozirna 107 2 You are already in the interactive terminal called psql, so try this query without $ psql mydb at start. –Kamil G. Sep 14 at 17:14 I've tried that option also. I've got the same output. –Eugenia Ozirna Sep 14 at 17:43 Don't enter psql at the psql prompt. –a_horse_with_no_name Sep 14 at 18:16 add a comment| active oldest votes Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook. Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Browse other questions tagged postgresql or ask your own question. asked 1 month ago viewed 29 times Related 912PostgreSQL “DESCRIBE TABLE”637S
8.0 / 8.1 / 8.2 / 8.3 / 8.4 / 9.0 PostgreSQL 9.0.23 Documentation Prev Up Next CREATE TABLE NameCREATE TABLE--define a new table Synopsis CREATE [ [ GLOBAL | LOCAL ] https://www.postgresql.org/docs/9.0/static/sql-createtable.html { TEMPORARY | TEMP } ] TABLE table_name ( [ { column_name data_type [ https://www.postgresql.org/message-id/legacy/pgsql-bugs/2012-01/msg00014.php DEFAULT default_expr ] [ column_constraint [ ... ] ] | table_constraint | LIKE parent_table [ like_option ... ] } [, ... ] ] ) [ INHERITS ( parent_table [, ... ] ) ] [ WITH ( storage_parameter [= value] [, ... ] ) | WITH OIDS | WITHOUT OIDS ] [ ON COMMIT { PRESERVE ROWS | DELETE syntax error ROWS | DROP } ] [ TABLESPACE tablespace ] CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name OF type_name [ ( { column_name WITH OPTIONS [ DEFAULT default_expr ] [ column_constraint [ ... ] ] | table_constraint } [, ... ] ) ] [ WITH ( storage_parameter [= value] [, ... ] ) | WITH OIDS | WITHOUT OIDS ] [ ON COMMIT { PRESERVE ROWS postgres create table | DELETE ROWS | DROP } ] [ TABLESPACE tablespace ] where column_constraint is: [ CONSTRAINT constraint_name ] { NOT NULL | NULL | CHECK ( expression ) | UNIQUE index_parameters | PRIMARY KEY index_parameters | REFERENCES reftable [ ( refcolumn ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE action ] [ ON UPDATE action ] } [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] and table_constraint is: [ CONSTRAINT constraint_name ] { CHECK ( expression ) | UNIQUE ( column_name [, ... ] ) index_parameters | PRIMARY KEY ( column_name [, ... ] ) index_parameters | EXCLUDE [ USING index_method ] ( exclude_element WITH operator [, ... ] ) index_parameters [ WHERE ( predicate ) ] | FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE action ] [ ON UPDATE action ] } [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] and like_option is: { INCLUDING | EXCLUDING } { DEFAULTS | CONSTRAINTS | INDEXES | STORAGE | COMMENTS | ALL } index_parameters in UNIQUE, PRIMARY KEY, and EXCLUDE constraints are: [ WITH ( storage_para
pgsql-announce pgsql-bugs pgsql-docs pgsql-general pgsql-interfaces pgsql-jobs pgsql-novice pgsql-performance pgsql-php pgsql-sql pgsql-students Developer lists Regional lists Associations User groups Project lists Inactive lists IRC Local User Groups Featured Users International Sites Propaganda Resources Weekly News BUG #6376: Cannot prepare a "CREATE TABLE" statement,error message is unhelpful From: agserm(at)gmail(dot)com To: pgsql-bugs(at)postgresql(dot)org Subject: BUG #6376: Cannot prepare a "CREATE TABLE" statement,error message is unhelpful Date: 2012-01-04 03:06:06 Message-ID: E1RiHB0-0003hL-8e@wrigleys.postgresql.org (view raw or whole thread) Thread: 2012-01-04 03:06:06 from agserm(at)gmail(dot)com 2012-01-04 14:48:57 from "Kevin Grittner"