Table creation error (ORA-00904)

Asked

Viewed 238 times

3

I don’t know if it’s my glasses that are in trouble, but I can’t see where I’m going wrong. If you can help me.

I read that the mistake could be happening by the way I’m declaring mine PRIMARY KEY, but I tried it three different ways and it didn’t work.

CREATE TABLE USUARIO_BI_TREINAMENTO_ATM(
                                        ID       NUMBER(22) NOT NULL,
                                        USER     VARCHAR2(2000) NOT NULL,
                                        PASSWORD VARCHAR2(2000) NOT NULL,
                                        TOKEN    VARCHAR2(400),
            CONSTRAINT USUARIO_BI_TREINAMENTO_PK PRIMARY KEY (ID)
);

The error is returned:

Error from line : 1 on command -

ORA-00904: Invalid identifier

  • It seems to me that you are using Oracle and not Microsoft SQL Server. See the list of reserved words in https://docs.oracle.com/cd/B19306_01/em.102/b40103/app_oracle_reserved_words.htm or check the view V$RESERVED_WORDS.

  • Yes, I am, thank you for observing.

1 answer

3


You cannot create a table with a column called USER, because this way the bank confuses itself with a language command, in order to create the column use the quotation marks "USER", as an example below:

CREATE TABLE USUARIO_BI_TREINAMENTO_ATM(
                                        ID       NUMBER(22) NOT NULL,
                                        "USER"     VARCHAR2(2000) NOT NULL,
                                        PASSWORD VARCHAR2(2000) NOT NULL,
                                        TOKEN    VARCHAR2(400),
            CONSTRAINT USUARIO_BI_TREINAMENTO_PK PRIMARY KEY (ID)
);

This also happens when you try to create a SET column (abbreviated September), OUT (abbreviated October) and other cases, just use the "" quotes.

  • 1

    I ended up discovering that PASSWORD is also a reserved word. : T But thanks! I ended up not paying attention to this detail.

  • 1

    I already had problem in a system with user log with a user MAX ...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.