This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Creating tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Creating tables" Watch "Creating tables" New topic
Author

Creating tables

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

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!


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
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.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating tables
 
Similar Threads
How to write a table in word document using apache poi
hibernate
JDBC doesn't retrieve all the results available in the MSSQL database
exporting html tables to excel
how to create sequence in mysql