/*
mysql> Drop table CDs;
mysql> CREATE TABLE CDs (
-> CDID SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
-> CDName VARCHAR(50) NOT NULL,
-> Copyright YEAR,
-> NumberDisks TINYINT UNSIGNED NOT NULL DEFAULT 1,
-> NumberInStock TINYINT UNSIGNED,
-> NumberOnReserve TINYINT UNSIGNED NOT NULL,
-> NumberAvailable TINYINT UNSIGNED NOT NULL,
-> CDType VARCHAR(20),
-> RowAdded TIMESTAMP
-> );
Query OK, 0 rows affected (0.28 sec)
mysql> INSERT INTO CDs VALUES
-> (NULL, 'Earle', 1996, 2, 10, 3, NumberInStock-NumberOnReserve, 'Country', NULL);
Query OK, 1 row affected (0.00 sec)
mysql> select * from CDs;
+------+--------+-----------+-------------+---------------+-----------------+-----------------+---------+---------------------+
| CDID | CDName | Copyright | NumberDisks | NumberInStock | NumberOnReserve | NumberAvailable | CDType | RowAdded |
+------+--------+-----------+-------------+---------------+-----------------+-----------------+---------+---------------------+
| 1 | Earle | 1996 | 2 | 10 | 3 | 7 | Country | 2005-10-09 09:19:46 |
+------+--------+-----------+-------------+---------------+-----------------+-----------------+---------+---------------------+
1 row in set (0.00 sec)
*/
Drop table CDs;
CREATE TABLE CDs (
CDID SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
CDName VARCHAR(50) NOT NULL,
Copyright YEAR,
NumberDisks TINYINT UNSIGNED NOT NULL DEFAULT 1,
NumberInStock TINYINT UNSIGNED,
NumberOnReserve TINYINT UNSIGNED NOT NULL,
NumberAvailable TINYINT UNSIGNED NOT NULL,
CDType VARCHAR(20),
RowAdded TIMESTAMP
);
INSERT INTO CDs VALUES
(NULL, 'Earle', 1996, 2, 10, 3, NumberInStock-NumberOnReserve, 'Country', NULL);
select * from CDs;
|