All this computer hacking is making me thirsty

SQL Commands

Posted by: ptilley125 on: March 23, 2009

SELECT * FROM table WHERE clause – grabs all information from the specified table based on the clause that is defined. For example if it the table contained students that hadn’t paid their tuition, a query can generate a list of people to remind (SELECT * FROM student WHERE payment tuition;)

INSERT into table VALUES() – adds data to the specified row. Use the term NULL to leave a field blank, separate each value using commas, and place any character value in quotes.

CREATE VIEW name AS SELECT… – Saves a query that can be recalled quickly and easily any time in the future.

UPDATE table SET value = new value WHERE clause – Change a specific value in a table when you want to make updates.

CREATE SEQUENCE name [START WITH number] [INCREMENT BY number] [CACHE | NO CACHE] – A sequence automatically creates the next number in a defined series. Using the INSERT command, use the sequence_name.NEXTVAL to allow a unique value. Use .CURRVAL after using .NEXTVAL to define the same number (i.e. a foreign key). Anything in brackets is an optional value to be defined.

Remember that all SQL lines should be ended by a semicolon (;).

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.