Java Reference
In-Depth Information
SQL is a standard, but most database vendors provide an extension to SQL
unique to their database. In this topic, I am going to show you the basics
of SQL, but keep in mind there is more to it than what is discussed here. I
will show you enough SQL to be able to create, read, update, and delete
(often referred to as CRUD operations) data from a database, which are
far and away the most common types of SQL operations.
Creating Data
The CREATE TABLE statement is used for creating a new table in a database.
The syntax is:
CREATE TABLE table_name
(
column_name column_data_type ,
column_name column_data_type ,
column_name column_data_type
...
)
For example, the following SQL statement creates a table named Employees
with four columns: number, which is an int; payRate, which is a double; and
first and last, which are strings of up to 255 characters.
CREATE TABLE Employees
(
number INT NOT NULL,
payRate DOUBLE PRECISION NOT NULL,
first VARCHAR(255) ,
last VARCHAR(255)
)
After you have a table created, you can insert rows into the table using the
INSERT statement. The syntax for INSERT looks similar to the following,
where column1, column2, and so on represent the new data to appear in the
respective columns:
INSERT INTO table_name VALUES ( column1, column2, column3, ...)
For example, the following INSERT statement inserts a new row in the
Employees database created earlier:
INSERT INTO Employees VALUES (101, 20.00, 'Rich', 'Raposa')
Search WWH ::




Custom Search