Oracle 23.26SQLLab-verified · 2026-11-28

ORA-00902: invalid datatype

A column's data type isn't one Oracle knows — usually a type name copied from another database, or a type you can't access.

Oracle AI Database 26ai Free 23.26.3.0.0
ORA-00902: invalid datatype

Jump to a cause

  1. 01MySQL DATETIME used in CREATE TABLE
  2. 02MySQL TEXT used for a long text column
  3. 03Object type in another schema used without EXECUTE privilege

Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-11-28 · container image gvenzl/oracle-free:23-slim

ORA-00902 means Oracle doesn't recognize the data type in a column definition. The asterisk in the error output points at the type. It typically happens when DDL from MySQL or SQL Server is run as is, or when a column uses an object type in another schema that you have no privilege on.

All three common cases were reproduced and fixed below.

01MySQL DATETIME used in CREATE TABLE

CREATE TABLE orders (... created_at DATETIME) failed with ORA-00902, with the asterisk under DATETIME. Oracle has no DATETIME type.

Oracle's DATE already stores the time down to seconds. After changing the column to DATE, a value inserted with TO_DATE('2026-11-28 10:30:15', 'YYYY-MM-DD HH24:MI:SS') came back as 2026-11-28 10:30:15.

Reproducerun as lab_a
CREATE TABLE orders (order_id NUMBER PRIMARY KEY, order_no VARCHAR2(20), created_at DATETIME);
✕ ERROR
CREATE TABLE orders (order_id NUMBER PRIMARY KEY, order_no VARCHAR2(20), created_at DATETIME)
                                                                                    *
ERROR at line 1:
ORA-00902: invalid datatype
Help: https://docs.oracle.com/error-help/db/ora-00902/
Fixrun as lab_a
CREATE TABLE orders (order_id NUMBER PRIMARY KEY, order_no VARCHAR2(20), created_at DATE);
OUTPUT
Table created.

If you need fractional seconds, use TIMESTAMP instead of DATE.

After the fixrun as lab_a
INSERT INTO orders VALUES (1, 'A-1001', TO_DATE('2026-11-28 10:30:15', 'YYYY-MM-DD HH24:MI:SS'));
SELECT order_id, order_no, TO_CHAR(created_at, 'YYYY-MM-DD HH24:MI:SS') AS created_at FROM orders;
✓ SUCCESS
1 row created.


  ORDER_ID ORDER_NO             CREATED_AT
---------- -------------------- -------------------
         1 A-1001               2026-11-28 10:30:15

1 row selected.

02MySQL TEXT used for a long text column

body TEXT failed with ORA-00902. Oracle has no TEXT type.

For long text, use CLOB. With body CLOB, the table was created and an 8,000-character value was stored (DBMS_LOB.GETLENGTH returned 8000).

Reproducerun as lab_a
CREATE TABLE notices (notice_id NUMBER PRIMARY KEY, title VARCHAR2(200), body TEXT);
✕ ERROR
CREATE TABLE notices (notice_id NUMBER PRIMARY KEY, title VARCHAR2(200), body TEXT)
                                                                              *
ERROR at line 1:
ORA-00902: invalid datatype
Help: https://docs.oracle.com/error-help/db/ora-00902/
Fixrun as lab_a
CREATE TABLE notices (notice_id NUMBER PRIMARY KEY, title VARCHAR2(200), body CLOB);
OUTPUT
Table created.

For short text, VARCHAR2(n) is the usual choice. CLOB is for values longer than that.

After the fixrun as lab_a
INSERT INTO notices VALUES (1, 'Maintenance', TO_CLOB(RPAD('a', 4000, 'a')) || RPAD('b', 4000, 'b'));
SELECT notice_id, DBMS_LOB.GETLENGTH(body) AS body_length FROM notices;
✓ SUCCESS
1 row created.


 NOTICE_ID BODY_LENGTH
---------- -----------
         1        8000

1 row selected.

03Object type in another schema used without EXECUTE privilege

lab_b owns the object type addr_t. When lab_a ran CREATE TABLE customers (..., addr lab_b.addr_t), it failed with ORA-00902, with the asterisk under lab_b.addr_t. The type exists, but lab_a can't use it.

After lab_b ran GRANT EXECUTE ON addr_t TO lab_a, the same CREATE TABLE succeeded, and a row with lab_b.addr_t('Seoul', '04524') was inserted and read back.

Setup
Setuprun as lab_b
CREATE TYPE addr_t AS OBJECT (city VARCHAR2(30), zip VARCHAR2(10));
/
OUTPUT
Type created.
Reproducerun as lab_a
CREATE TABLE customers (cust_id NUMBER PRIMARY KEY, addr lab_b.addr_t);
✕ ERROR
CREATE TABLE customers (cust_id NUMBER PRIMARY KEY, addr lab_b.addr_t)
                                                               *
ERROR at line 1:
ORA-00902: invalid datatype
Help: https://docs.oracle.com/error-help/db/ora-00902/
Fixrun as lab_b
GRANT EXECUTE ON addr_t TO lab_a;
OUTPUT
Grant succeeded.

The error says 'invalid datatype', not 'insufficient privileges', so check the type's owner and grants when the type name looks correct.

After the fixrun as lab_a
CREATE TABLE customers (cust_id NUMBER PRIMARY KEY, addr lab_b.addr_t);
INSERT INTO customers VALUES (1, lab_b.addr_t('Seoul', '04524'));
SELECT c.cust_id, c.addr.city AS city, c.addr.zip AS zip FROM customers c;
✓ SUCCESS
Table created.


1 row created.


   CUST_ID CITY                           ZIP
---------- ------------------------------ ----------
         1 Seoul                          04524

1 row selected.

FAQ

What does ORA-00902 invalid datatype mean?

Oracle doesn't recognize the data type in a column definition. Check the word under the asterisk: it's often a type from another database or a type you have no access to.

What is the Oracle equivalent of DATETIME?

DATE, which stores date and time to the second. Use TIMESTAMP if you need fractional seconds.

What is the Oracle equivalent of the TEXT type?

CLOB for long text, or VARCHAR2(n) for text with a known maximum length.

Why do I get ORA-00902 when using another user's object type?

You need EXECUTE on that type. The owner runs GRANT EXECUTE ON type_name TO your_user, and the column definition works.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary users created for the test; system is the DBA account. Oracle AI Database 26ai Free Release 23.26.3.0.0 - Develop, Learn, and Run for Free 23.26.3.0.0