Posts

Showing posts from November, 2014

SQL: ALTER TABLE STATEMENT

This SQL tutorial explains how to use the SQL  ALTER TABLE statement  to add a column, modify a column, drop a column, rename a column or rename a table (with lots of clear, concise examples). We've also added some practice exercises that you can try for yourself. DESCRIPTION The SQL  ALTER TABLE statement  is used to add, modify, or drop/delete columns in a table. The SQL ALTER TABLE statement is also used to rename a table. ADD COLUMN IN TABLE Syntax To add a column in a table, the SQL ALTER TABLE syntax is: ALTER TABLE table_name ADD column_name column-definition; Example Let's look at a SQL ALTER TABLE example that adds a column. For example: ALTER TABLE supplier ADD supplier_name varchar2(50); This SQL ALTER TABLE example will add a column called  supplier_name  to the  supplier  table. ADD MULTIPLE COLUMNS IN TABLE Syntax To add multiple columns to an existing table, the SQL ALTER TABLE syntax is: ALTER TABLE table_name ADD (column_1 c...

SQL CREATE TABLE Statement

The SQL CREATE TABLE Statement The CREATE TABLE statement is used to create a table in a database. Tables are organized into rows and columns; and each table must have a name. SQL CREATE TABLE Syntax CREATE TABLE  table_name ( column_name1 data_type ( size ), column_name2 data_type ( size ), column_name3 data_type ( size ), .... ); The column_name parameters specify the names of the columns of the table. The data_type parameter specifies what type of data the column can hold (e.g. varchar, integer, decimal, date, etc.). The size parameter specifies the maximum length of the column of the table. Example CREATE TABLE Persons ( PersonID int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255) );

Applications of a Queue in Daily life

Image
Definition of Queue A Queue is "an abstract data type in which elements are added to the rear and removed from the front; a 'first in, first out' (FIFO) structure."  ( C++ Plus Data Structures , page 226) The main difference between a queue and a stack is that elements in a queue are put on the bottom and taken off the top (remember, in a stack, elements put on the top and taken off the top). For an everyday queue example, consider a line of customers at a bank waiting to be served. Each new customer gets in line at the rear. When the teller is ready to help a new customer, the customer at the front of the line is served. This is a queue--the first customer in line is the first one served. 1.1 Applications of a Queue In general, queues are often used as "waiting lines". Here are a few examples of where queues would be used: In operating systems, for controlling access to shared system resources such as printers, files, communication lines, disks and tapes.A ...