Forums Register Login

Creating tables

+Pie Number of slices to send: Send
Guys,

When I'm creating tables, it I say just PRIMARY KEY is it enough for it to be NOT NULL and UNIQUE? Please let me know!
+Pie Number of slices to send: Send
Those are the criteria for a primary key. You still need to identify it is a primary key.

Since this is about tables and not specific to Oracle, I'm moving it to our JDBC forum.
+Pie Number of slices to send: Send
A primary key is a lot more than just a non-null, unique field. The primary key is the field (or group of fields) which serve to uniquely identify a row. By declaring a primary key you are giving the database lots of information about how the table is structured and which columns depend on which others.

Primary key fields are almost always indexed, and defining a primary key is vital if you want to use foreign keys in other tables which reference this one, or features such as "REPLACE INTO" (which updates an existing matching row or inserts a new one if there is no existing row with the same key.)

The bottom line is that I can't think of a situation in which you should not define a primary key.
Oh the stink of it! Smell my tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 900 times.
Similar Threads
exporting html tables to excel
hibernate
How to write a table in word document using apache poi
how to create sequence in mysql
JDBC doesn't retrieve all the results available in the MSSQL database
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 00:44:21.