postgresql 错误:创建新表时“(”处或附近的语法错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21716853/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ERROR: syntax error at or near "(" when creating a new table
提问by CoolLife
I am extremely new to PostgreSQL and every time I try to create a new table, I run into the following error:
我对 PostgreSQL 非常陌生,每次尝试创建新表时,都会遇到以下错误:
ERROR: syntax error at or near "(" LINE 1: ..." ("id_azucarusuario"
SERIAL, "id_usuario" integer(128) NOT ...
Here is the SQL for the table I am trying to define:
这是我试图定义的表的 SQL:
CREATE TABLE "public"."usuario_azucar"
( "id_azucarusuario" SERIAL,
"id_usuario" integer(128) NOT NULL,
"codigogeneral" character varying(240) NOT NULL,
"razonsocial" character(240),
"nombrecomercial" character(240),
"nit" integer(128),
"nummatricula" integer(128),
"direccionempresa" character(240),
"subdepartamento" character(240),
"subciudad" character(240),
"subdireccion" character varying(240),
"subcalle" character varying(240),
"subreferencia" character varying(240),
"subtelefono" integer(128),
"subpagweb" character(240),
"subemail" character varying(240),
"rai" character varying(240),
"descripcion_proceso_azucar" character varying(240),
"descripcion_proceso_alcohol" character varying(240),
"balance_energeticoomasic" character varying(240),
"productos_obtenidos" character varying(240),
"capacidad_azuoalco" character varying(240),
"capacidadreal_azuoalcoho" character varying(240),
PRIMARY KEY ("id_azucarusuario")
)
WITHOUT OIDS;
回答by Daniel Sparing
There is no type as integer(...)
, choose smallint
, integer
or bigint
given the ranges here:
http://www.postgresql.org/docs/current/interactive/datatype-numeric.html
没有类型integer(...)
,选择smallint
,integer
或者bigint
在这里给出的范围:
http://www.postgresql.org/docs/current/interactive/datatype-numeric.html
回答by Nakul Panwar
Do not use any reserved keywords..
不要使用任何保留关键字..
You must change the table name from 'public' to something else.. as it is a reserved keyword on postgresql..
您必须将表名从“ public”更改为其他名称.. 因为它是 postgresql 上的保留关键字..