Sunday, September 28, 2014

SQL – Data Definition - 3

DROP TABLE….


  • Delete table definition permanently from the database
  • DROP TABLE Modules
  • Can not recover again unless you use a database backup



MODIFYING TABLES…

  • Add an extra column
  • Drop a column
  • Modify the data type or length
  • Add a new table constraint
  • Drop a table constraint
  • Change a column property (Ex: DEFAULT VALUE, NULL NOT NULL, etc)


ALTER TABLE…

  • ALTER TABLE Lecturers
          ADD COLUMN roomNo SMALLINT
  • ALTER TABLE Lecturers
         ALTER COLUMN staffName VARCHAR(20)
  • ALTER TABLE Lecturers
        DROP COLUMN staffName 
  • ALTER TABLE Lecturers
       ALTER COLUMN level SET DEFAULT 3



No comments:

Post a Comment