I have created a table with column S_ROLL NUMBER(3) NOT NULL
Now I want to make this colum to as identity column.
I used this command
alter table students
modify
(
S_ROLL NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY
);
Then I'm getting this error.
S_ROLL NUMBER GENERATED BY DEFAULT ON NULL AS IDENTITY
*
ERROR at line 4:
ORA-30673: column to be modified is not an identity column
In any case, you cannot modify an identity column, so you have to delete the row and re-add with new identity. You cannot remove the identity property from the column (you would have to remove to column)
You cannot alter a column to be an IDENTITY column. What you'll need to do is create a new column which is defined as an IDENTITY from the get-go, then drop the old column, and rename the new one to the old name.
Sadly you can't alter an existing column to become an identity. This assigns a value from the sequence to all existing rows.
An INTEGER, LONG, or NUMBER column in a table can be defined as an identity column. The system can automatically generate values for the identity column using a sequence generator. See Sequence Generator section. A value for an identity column is generated during an INSERT, UPSERT, or UPDATE statement.
You're getting this error simply because modifying an existing column as IDENTITY column is not supported right now.
The solution is to add a new column and then drop the existing one (making sure that you do take care of the data too).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With