CHAPTER 28 FROM DATABASES TO DATATYPES Finally, (Web site management)
CHAPTER 28 FROM DATABASES TO DATATYPES Finally, after all that, you decide that it really isn t necessary to track the employee s birth date. Go ahead and delete the column: ALTER TABLE employee DROP COLUMN birthdate; Working with Sequences Sequences are special database objects created for the purpose of assigning unique numbers for input into a table. Sequences are typically used for generating primary key values, especially in cases where you need to do multiple concurrent inserts but need the keys to remain unique. Let s now look at how to work with sequences. Creating a Sequence The syntax for creating a sequence is as follows: CREATE [ TEMPORARY | TEMP ] SEQUENCE name [ INCREMENT [ BY ] increment ] [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ] [ START [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ] The TEMPORARY and TEMP keywords indicate that the sequence should be created only for the existing session and then dropped on session exit. By default, a sequence increments one at a time, but you can change this by using the optional INCREMENT BY keywords. The MINVALUE and MAXVALUE keywords work as expected, supplying a minimum and maximum value for the sequence to generate. The default values are 1and 263 (roughly 9 million trillion) 1. The START WITH keywords allow you to specify an initial number for the sequence to begin with other than 1. The CACHE option allows you to specify a number of sequence values to be pre-allocated and stored in memory for faster access. Finally, the CYCLEand NO CYCLE options control whether the sequence should wrap around to the starting value once MAXVALUE has been reached, or should throw an error, which is the default behavior. Modifying Sequences You can modify the majority of values of a sequence by using the ALTER SEQUENCE command. The syntax is as follows: ALTER SEQUENCE name [ INCREMENT [ BY ] increment ] [ MINVALUE minvalue | NO MINVALUE ] [ MAXVALUE maxvalue | NO MAXVALUE ] [ RESTART [ WITH ] start ] [ CACHE cache ] [ [ NO ] CYCLE ] As you can see, the ALTER SEQUENCE command follows the same structure as the CREATE SEQUENCE command, and its keywords match those of the former command as well. Additionally, starting in PostgreSQL 8.1, you can issue the following command to change which schema a sequence is located in: ALTER SEQUENCE name SET SCHEMA new_schema
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.