11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 28 • MYSQL STORAGE ENGINES AND DATA TYPESwww.it-ebooks.infoCreating a single-field primary key:CREATE TABLE citizens (id VARCHAR(9) NOT NULL,firstname VARCHAR(15) NOT NULL,lastname VARCHAR(25) NOT NULL,zipcode VARCHAR(9) NOT NULL,PRIMARY KEY(id));Creating a multiple-field primary key:CREATE TABLE friends (firstname VARCHAR(15) NOT NULL,lastname VARCHAR(25) NOT NULL,nickname varchar(15) NOT NULL,PRIMARY KEY(lastname, nickname));UNIQUEA column assigned the UNIQUE attribute will ensure that all values possess distinct values, except thatNULL values are repeatable. You typically designate a column as UNIQUE to ensure that all fields within thatcolumn are distinct—for example, to prevent the same e-mail address from being inserted into anewsletter subscriber table multiple times, while at the same time acknowledging that the field couldpotentially be empty (NULL). An example of a column designated as UNIQUE follows:email VARCHAR(55) UNIQUEZEROFILLThe ZEROFILL attribute is available to any of the numeric types and will result in the replacement of allremaining field space with zeroes. For example, the default width of an unsigned INT is 10; therefore, azero-filled INT value of 4 would be represented as 0000000004. An example of a ZEROFILL attributeassignment follows:odometer MEDIUMINT UNSIGNED ZEROFILL NOT NULLGiven this definition, the value 35,678 would be returned as 0035678.Working with Databases and TablesLearning how to manage and navigate <strong>MySQL</strong> databases and tables is one of the first tasks you’ll want tomaster. This section highlights several key tasks.Working with DatabasesThis section demonstrates how to view, create, select, and delete <strong>MySQL</strong> databases.546

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!