如何在不使用约束名称的情况下从中删除主键

Rag*_*hav 2 oracle primary-key oracle11g

CREATE TABLE Persons (
    ID int PRIMARY KEY,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int
);
Run Code Online (Sandbox Code Playgroud)

由于没有定义约束,如何删除主键?

APC*_*APC 7

“由于没有定义约束,如何删除PK?”

实际上,它就像您希望的那样简单:

SQL> create table t23 (id number primary key);

Table created.

SQL> select constraint_name, constraint_type
  2  from user_constraints
  3  where table_name = 'T23'
  4  /

CONSTRAINT_NAME                C
------------------------------ -
SYS_C0034419                   P

SQL> alter table t23 drop primary key;

Table altered.

SQL> select constraint_name, constraint_type
  2  from user_constraints
  3  where table_name = 'T23'
  4  /

no rows selected

SQL> 
Run Code Online (Sandbox Code Playgroud)