quick tutorial

Quick tutorial:

in this tutorial, blue text is what the program outputs, red text is what you type in.

What this will show you is how to create an INSERT INTO query which contains one row of values that gets stored into an output file aptly named "output.txt" as well as being printed to the screen.

1) You have a CREATE TABLE query in a text file name product_table.txt:

------begin example text file------

CREATE TABLE products(

product_name CHAR(40) NOT NULL,

product_price INT, /*price in us dollars */

exp_date DATE,

product_id INT PRIMARY KEY

);

-----end example file-----

2) Pass that file name as an argument to sqg and put the query

The -i is to create an INSERT INTO query, and the -p is to print the output

query to the screen when you're done. The query you make will be stored

in output.txt (the output file is optional if you are using the -p option).

bash$]sqg -i -p product_table.txt output.txt

3) the program will then show you this:

Table name

products

Type in the name of the table you want to make a query for [ ] products

3) Since products is the only table in the example file, type "products" and press enter

4) you will then get a prompt for to enter data for each column:

the red text is what you type in.

Enter value for product_name (datatype CHAR) Joe's Potato Chips

Enter value for product_price (datatype INTEGER) 1.50

Enter value for exp_date (datatype DATE) 2012-06-01

Enter value for product_id (datatype INTEGER) 241

Here is your query:

INSERT INTO products(product_name, product_price, exp_date, product_id)

VALUES('Joe\'s Potato Chips', 1.50, {d '2012-06-01'}, 241);

Are you done making INSERT INTO queries?(y/N)y

Thank you for using SQL Query Generator 1.0

bash$]