You are on page 1of 6

What Is a Query?

A query is a question you ask of your database. You can: display data from multiple tables control which fields display perform calculations on field values save a query automatically

What does this mean?


CREATE TABLE employee
(ssn VARCHAR(9) NOT NULL, first VARCHAR(15), last VARCHAR(20) NOT NULL);

Language explained
CREATE TABLE tablename Add the ) mark!

(column1 datatype, column2 datatype, column3 datatype );


create table means create a table ( begin defining fields with a ( ) end of fields is signaled by ) ; end of statement

Validation, Constraints
The database automatically checks that entered data is appropriate to the field type If the field is a phone number, you can create a constraint that input is to be numbers only and no letters are allowed.
NOT NULL means that the column must have a value in each row. If NULL is used, that column may be left empty in a given row.

Starting to make sense?


Table name CREATE TABLE employee (ssn CHAR(11) NOT NULL, first VARCHAR(15), last VARCHAR(20) NOT NULL, age INT(3), Field names: address VARCHAR(30), Datatype: city VARCHAR(20), state CHAR(2));

Language Layout

"column1" "datatype" [constraint],

ssn CHAR(11) NOT NULL

You might also like