0

I am new to writing SQL and using Oracle... so I'm sorry if this is obvious but I can't figure it out. It's telling me that I'm missing a right parenthesis but as far as I can tell they are all there. It seems to be a problem with the VARBINARY line but I don't know why.

CREATE TABLE DATA_VALUE
(
    DATA_ID         VARCHAR2(40) NOT NULL,
    POSITION        INT NOT NULL,
    VALUE           VARCHAR2(50),
    BINARY_VALUE    VARBINARY(50),
    DATA_TYPE       VARCHAR2(20),

    CONSTRAINT DATA_VALUE_PK PRIMARY KEY(DATA_ID, POSITION)
);
user1451495
  • 309
  • 3
  • 5
  • 9

1 Answers1

3

VARBINARY is not an Oracle data type. A quick search suggests MySQL and SQL Server have it, at least, but not Oracle. Perhaps you need to explain what you want to store in that field. The closest I can think you might mean is RAW.

The valid built-in datatypes are listed in the documentation:

The RAW and LONG RAW data types store data that is not to be explicitly converted by Oracle Database when moving data between different systems. These data types are intended for binary data or byte strings.

This Microsoft article suggests you should be using RAW as a replacement for VARBINARY too, at least for the size you're talking about.

CREATE TABLE DATA_VALUE
(
    DATA_ID         VARCHAR2(40) NOT NULL,
    POSITION        INT NOT NULL,
    VALUE           VARCHAR2(50),
    BINARY_VALUE    RAW(50),
    DATA_TYPE       VARCHAR2(20),

    CONSTRAINT DATA_VALUE_PK PRIMARY KEY(DATA_ID, POSITION)
);

table DATA_VALUE created.
Alex Poole
  • 183,384
  • 11
  • 179
  • 318