How to Set Primary Key in Toad for Oracle?

How to Set Primary Key in Toad for Oracle?

  • Toad
  • 1 min read

In this tutorial, you will learn how to set the primary key in Toad for Oracle.

Follow These Steps to Set the Primary Key for a Table in Toad for Oracle

  1. Open Toad for Oracle and login to your database.
  2. Then click on the menu Database > Schema Browser.
  3. In the schema browser window, select the table for which you want to set the primary key.
  4. Then do the right click on the selected table and select Alter Table option from the shortcut menu.
  5. Now table will open in edit mode in Toad for Oracle.
  6. Then click the checkbox for the columns you want to set the primary key as shown in the below image.

Set primary key for a table using Toad for Oracle

  1. After selecting the columns click on the OK button to apply.

Also, before clicking on the OK button, you can click on the Show SQL button to view the SQL statement for the current changes you have made. For example, for the above change below is the script.

ALTER TABLE EMP ADD (
CONSTRAINT EMP_PK
PRIMARY KEY
(EMPNO))
/

You can run the above Alter Table statement in SQL editor of Toad and press F9 to run.