sql queries

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mo/-/sin

    sql queries

    i made a table and there is a column name departmentid(th is 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.......
  • Philipp Post

    #2
    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

    Comment

    • Philipp Post

      #3
      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

      Comment

      Working...