topical media & game development

talk show tell print

basic-mysql-05-ch05-TryItOut.sql / sql



  
  /* Chapter 5 - Try It Out sections */
  
  /* Try It Out: Altering and Dropping Tables */
  
  CREATE TABLE InStock
  (
     ProductID SMALLINT
  );
  
  ALTER TABLE InStock
  ADD COLUMN Quantity SMALLINT UNSIGNED NOT NULL,
  MODIFY ProductID SMALLINT UNSIGNED NOT NULL,
  ADD PRIMARY KEY (ProductID);
  
  ALTER TABLE InStock
  DROP COLUMN Quantity,
  DROP PRIMARY KEY;
  
  /* Try It Out: Creating a Table with an Index */
  
  CREATE TABLE CDs
  (
     CDID SMALLINT UNSIGNED NOT NULL,
     CDName VARCHAR(40) NOT NULL,
     INDEX (CDName)
  );
  
  /* Try It Out: Creating an Index with the ALTER TABLE Statement */
  
  CREATE TABLE CDs
  (
     CDID SMALLINT UNSIGNED NOT NULL PRIMARY KEY,
     CDName VARCHAR(40) NOT NULL
  );
  
  /* Try It Out: Creating an Index with the CREATE INDEX Statement */
  
  CREATE TABLE CDs
  (
     CDID SMALLINT UNSIGNED NOT NULL PRIMARY KEY,
     CDName VARCHAR(40) NOT NULL
  );
  
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.