Skip to Main Content
  • Questions
  • Alter table to include NOT NULL on a LONG datatype column

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Michelle.

Asked: June 17, 2024 - 8:11 pm UTC

Last updated: June 18, 2024 - 4:33 am UTC

Version: 19c

Viewed 1000+ times

You Asked

Hello,
I am trying to figure out why this answer is correct regarding a LONG data type.
Here is the question

EMP_DETAILS table
Name       NULL          TYPE
EMP_ID     NOT NULL     NUMBER
EMP_NAME   NOT NULL     VARCHAR2(40)
EMP_IMAGE               LONG


What statements are true regarding SQL statements that can be executed on the table

A- An EMP_IMAGE cannot be included in the ORDER BY (correct you cannot have a LONG in an ORDER BY)

B_-You can alter the table to include the NOT NULL constraint on the EMP_IMAGE column (I don't understand why this is NOT TRUE)

C- You cannot add a new column to the table with LONG as the data type (Correct- you can only have one LONG datatype in a table)

D- AN EMP_IMAGE column can be included in the GROUP BY clause (incorrect- you cannot have a LONG datatype in a GROUP BY)

SO, is there a reason why I cannot ALTER this table to include a NOT NULL on a LONG datatype?
Thanks

and Connor said...

I think you can ...

SQL> create table t (x int, y long );

Table created.

SQL> insert into t values (1,'x');

1 row created.

SQL> commit;

Commit complete.

SQL> alter table t modify y not null;

Table altered.


That looks like an assessment style question - it might be out of date.


Is this answer out of date? If it is, please let us know via a Comment