Difference between revisions of "MySQL"

Jump to navigation Jump to search
119 bytes added ,  10:07, 22 February 2011
→‎CREATE / ALTER Tables: Added further ALTER example
(→‎CREATE / ALTER Tables: Added further ALTER examples)
(→‎CREATE / ALTER Tables: Added further ALTER example)
Line 108: Line 108:
<br>'''ALTER'''<br>
<br>'''ALTER'''<br>
<source lang="mysql">
<source lang="mysql">
ALTER TABLE hware ADD UNIQUE KEY hid;                                        # Add index/key (using existing column)
ALTER TABLE hware ADD UNIQUE KEY hid;                                        # Add additional index/key (using existing column)
ALTER TABLE hware ADD FULLTEXT(name);                                        # Add a FULLTEXT key (used for fuzzy searches)
ALTER TABLE hware ADD FULLTEXT(name);                                        # Add a FULLTEXT key (used for fuzzy searches)
ALTER TABLE hware ADD COLUMN cpu_core TINYINT UNSIGNED AFTER cpu_num;        # Add new column
ALTER TABLE hware ADD COLUMN cpu_core TINYINT UNSIGNED AFTER cpu_num;        # Add new column
Line 115: Line 115:
ALTER TABLE hware DROP COLUMN cpu_sock;                                      # Drop (delete/remove) column from table
ALTER TABLE hware DROP COLUMN cpu_sock;                                      # Drop (delete/remove) column from table
ALTER TABLE hware DROP KEY hid;                                              # Drop (delete/remove) hid index (not the column)
ALTER TABLE hware DROP KEY hid;                                              # Drop (delete/remove) hid index (not the column)
ALTER TABLE hware DROP PRIMARY KEY;                                          # Drop primary key from table
</source>
</source>


Navigation menu