View Full Version : Erro PostgreSQL


Insurrecto
13-03-2008, 16:23
Como corrigir esta query:

create index i_o_totalprice on orders(order by o_totalprice desc);

dá este erro:

ERROR: syntax error at or near "order"
Estado de SQL:42601
Carácter:39


Se alguém souber agradecia.

slack_guy
13-03-2008, 17:24
Desculpa lá a pergunta, mas onde é que viste documentada essa sintaxe (order by) para o 'CREATE INDEX (http://www.postgresql.org/docs/8.3/static/sql-createindex.html)' ?

Insurrecto
13-03-2008, 22:59
pois tinha aí um erro, mas agora tenho outro:

drop schema if exists tpch;
commit;
create schema if not exists tpch;
use tpch;
commit;
drop table if exists PART;
create table PART (
P_PARTKEY int comment "identifier SF*200,000 are populated",
P_NAME varchar(55) comment "variable text, size 55",
P_MFGR char(25) comment "fixed text, size 25",
P_BRAND char(10) comment"fixed text, size 10",
P_TYPE varchar(25) comment " variable text, size 25",
P_SIZE int,
P_CONTAINER char(10) comment "fixed text, size 10",
P_RETAILPRICE decimal(13,2),
P_COMMENT varchar(23) comment "variable text, size 23"
/** Primary Key: P_PARTKEY **/
);

DÁ ESTE ERRO:

ERROR: syntax error at or near "not"
Estado de SQL:42601
Carácter:108

E RETIRAR O NOT DÁ ERRO NO USE... ALGUÉM?

slack_guy
13-03-2008, 23:15
Desculpa lá perguntar novamente.... mas estás a inventar alguma sintaxe nova para o Postgres? CREATE SCHEMA (http://www.postgresql.org/docs/8.3/static/sql-createschema.html).
O 'USE' não conheço. Não estarás a fazer confusão com o MySQL?!

Insurrecto
14-03-2008, 02:38
Desculpa lá perguntar novamente.... mas estás a inventar alguma sintaxe nova para o Postgres? CREATE SCHEMA (http://www.postgresql.org/docs/8.3/static/sql-createschema.html).
O 'USE' não conheço. Não estarás a fazer confusão com o MySQL?!

Isto deve ser mesmo MySQL mas tinha de passar isto para postgres... agora já consegui. obrigado na mesma.