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