Introduction to SQL: Getting StartedA Query Language for Relational Database Management Systems
Structured query language (SQL) is used to create databases, and retrieve and manipulate data. It is the standard query language for relational database management system
The first company to successfully put a product on the market using SQL was Oracle Corporation. It was based on the ideas put forth by E. Codd in his paper “A Relational Model of Data for Large Shared Data Banks”. According to an article written by Ron Plew and Ryan Stephens called “Welcome to the World of SQL” the American National Standards Institute (ANSI) approved SQL for relational databases in the 1980’s. Soon after the international community through the International Standards Organization (ISO) did the same. The SQL DatabaseA SQL database is a relational database where information is organized into tables. The information on each table is closely related the information on one or more tables in the database. Creating a new database can be accomplished by the following command: CREATE DATABASE name_of_database;. Many database applications also allow you to create a new database through an interface. Creating and Manipulating a TableThe structure of any relational database consists of tables with information arranged in a series of columns and rows. The commands found in the data definition section of SQL are used to create and change tables. They include, but are not limited to: CREATE, ALTER and DROP. CREATE TABLE creates a new table in a database where the user can assign specific properties to each column. An example is: CREATE TABLE Employees ( Employeeid int, Lastname varchar(50), Firstname varchar(50), Startdate date ) The resulting table is named ‘Employees’ and has four columns each with a specific data type. Data types designate the kind of data, such as characters, numbers or dates that are assigned to a column. The Employeeid column will have data that consists of int, or integer, values. ALTER and DROP commands are used to manipulate tables that already exist. ALTER can be used to add a column or change the data types in an existing table. In SQL the syntax for adding a column with ALTER is: ALTER TABLE name_of_table ADD name_of_column datatype; Changing an existing column follows this syntax: ALTER TABLE name_of_table ALTER COLUMN name_of_column datatype; DROP TABLE can be used to delete a table from a database while adding DROP COLUMN to an ALTER statement will remove a column from a table as follows: ALTER TABLE name_of_table DROP COLUMN name_of_column; Other CommandsINSERT and DELETE are more commands that manipulate data in SQL. SELECT, FROM and WHERE are important query commands. These commands will be reviewed in Introduction to SQL: SELECT, FROM, WHERE and More. Additional Sources: MySQL Documentation http://dev.mysql.com/doc/
The copyright of the article Introduction to SQL: Getting Started in Computer Programming is owned by Jennifer Graham. Permission to republish Introduction to SQL: Getting Started in print or online must be granted by the author in writing.
Related Topics
Reference
More in Technology
|