H
Amazon.com: PC Books || Educational Software || Magazines
Amazon: Books-CA || Software-CA || Books-UK || Software-UK

HTML | Javascript | ASP | PHP | VBScript | SQL | Hardware | PC FAQ| WinXP|

Learn to Build, Upgrade, or Repair your Computer Ebook + PC Safety 101 kwwebservice.com Reasonably priced web development & hosting
SQL Basics
Introduction
Create Tables
Data Type
Delete/Modify Table
Add Rows
Create Sequence
Quiries
Single-Row Function
Group Functions
Joints
Create Views
Books @
CA Amazon
UK Amazon
US Amazon

  :: Home
PC Topics
  :: Build A PC
  :: Windows XP
  :: PC Help
Tutorials
  :: HTML
  :: JavaScript
  :: ASP
  :: PHP
  :: VBScript
  :: SQL
Miscellaneous
  :: Code/Scripts
  :: Forum
  :: Links
  :: Contact us
  :: Tell A Friend
  :: In Somali
  ::
Web Articles
  Top Web Hosting
Reviews
  Processing
Online Card Payment Guide
  Domain name
registration & buying guide
  Getting
a website online guide
  Search Engine
submission & optimization tips
Netfirms Web Hosting
Free trial
Quality business correspondence.
Yahoo! Search Marketing

Creating SQL Sequences

Sequences are database objects that automatically generate sequential lists of numbers and they are usefull when creating surrogate key values for primary key fields.  For example, you can generate range of numbers starting from 1 to up when new record is added to the table, 1 could be value of the primary field for the first record and so on.   Every sequence must have unique name.  The first command and the only required command is CREAT SEQEUNCE which creates the sequence.   Sequence name follows this command and the rest of the commands such as START WITH, INCREMENT BY, MAXVALUE, MINVALUE, CYCLE, CACHE, ORDER, etc are optional.

Here is an example to create a sequence:
CREATE SEQUENCE employee_number_sec
   START WITH 1
   INCREMENT BY 1
This example simply creates a sequence called employee_number_sec that starts with 1 and increments by 1 each time the sequence runs new record.

When the sequence is created, the next thing you want do is insert into a table. Say that you want insert a sequence value for employee_id field in the employee table.  Here is how you would accomplish that:
INSERT INTO employees VALUES
(
   employee_number_sec.NEXTVAL, 00000234,'J','Morgan',
);
We inserted one record into the employees table using sequence generated values for the employees_id field.
NEXTVAL is a command that generates next available for the sequence.  Remember you have to have record in the department table with department_id of 0000234 in order to insert this record successfully.   You can view the current available sequence value by issuing this command:
SELECT employee_number_sec.CURRVAL FROM DUAL;  You can also view all the sequences you created from dual by this command:
SELECT * FROM user_sequence;.

Insert Records Retrieve Data
Bluehost.com Web Hosting $6.95
Listed @ ConsumerVote.com - The Consumer Rated Web Directory
PC System Tools
SpyCleaner
Registry Mechanic
4Diskclean Pro
Health PC Club
TweakNow
Registry Washer
SpyAnyWhere
System Lifeguard
...More/Details

PC Articles
  Computer Safety
prevent viruses & Spyware