0

Using EnterpriseDB I am not able to create/drop SYNONYM with name 'END'

DROP SYNONYM END;
CREATE SYNONYM END FOR TABLENAME;

I am getting similar issue while creating table with column name REFERENCES:

create tab1
( name character varying(250), 
REFERENCES character varying(250) ) 

I am converting the table from Oracle to Postgres (EntrepriseDB). In Oracle (END, REFERENCES) are used. Hence I need to use the same words here, too. Is there any way to use the reserved key words as synonyms name and column name?

  • 3
    I can see the code as a nightmare: SELECT CASE "END" WHEN 'END' THEN NAME ELSE "END" END "END", ... – ypercubeᵀᴹ Oct 17 '16 at 9:46
  • with double quotes it is started working – asalthangam Oct 17 '16 at 10:00
3

END and REFERENCES are both reserved keywords.

So if you really want to use them as names (of tables, columns, schemata, synonyms, ... whatever), you have to double-quote them, the same way as in Oracle:

CREATE SYNONYM "END" ... ;
DROP SYNONYM "END" ;

CREATE tab1
( name character varying(250), 
  "REFERENCES" character varying(250)
) ;

The problem is that you have to always double-quote them everywhere and match the case. "END" is not the same as "End" nor "end" nor "eNd", etc.

It would be much easier to use non-reserved words for all identifiers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.