Connecting Tech Pros Worldwide Help | Site Map

sql queries

  #1  
Old August 18th, 2008, 10:55 AM
mo/-/sin
Guest
 
Posts: n/a
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

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

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
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a batch of sql queries? mark.a.lemoine@gmail.com answers 7 March 2nd, 2006 08:05 PM
xslt queries in xml to SQL queries Ian Roddis answers 3 February 26th, 2006 07:05 PM
3 SQL queries in 1 string...in what order will they execute? rooster575 answers 2 November 18th, 2005 03:09 PM
How to handle sql queries Mikael Janers answers 4 November 15th, 2005 07:46 AM
Intercept SQL Queries sent to DB Vlade answers 1 July 20th, 2005 02:27 AM