Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 18th, 2008, 10:55 AM
mo/-/sin
Guest
 
Posts: n/a
Default sql queries

i made a table and there is a column name departmentid(this is the
primary key) and there is one another column name department name... i
want that this column should not accept the same value... i mean to
say that every row in this column should be unique. how can i do
this.......
  #2  
Old August 18th, 2008, 01:05 PM
Philipp Post
Guest
 
Posts: n/a
Default Re: sql queries

This is done by creating a UNIQUE constraint on department_name

CREATE TABLE Departments
(department_id NOT NULL PRIMARY KEY,
department_name NOT NULL UNIQUE)

brgds

Philipp Post

  #3  
Old August 18th, 2008, 01:15 PM
Philipp Post
Guest
 
Posts: n/a
Default Re: sql queries

well, and do not forget the datatype:

CREATE TABLE Departments
(department_id INTEGER NOT NULL PRIMARY KEY,
department_name VARCHAR(30) NOT NULL UNIQUE)

brgds

Philipp POst
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles