> creating tables in java ~ Online tutorial

creating tables in java

Creating a Table



First, we will create one of the tables in our example database. This table, COFFEES ,
contains the essential information about the coffees sold at The Coffee Break, including
the coffee names, their prices, the number of pounds sold the current week, and the
number of pounds sold to date. The table COFFEES , which we describe in more detail
later, is shown here:
COF_NAME SUP_ID PRICE SALES SALES TOTAL
AA 10 20 30
BB 30 20 50
The column storing the coffee name is COF_NAME, and it holds values with an SQL
type of VARCHAR and a maximum length of 32 characters. Since we will use different
names for each type of coffee sold, the name will uniquely identify a particular coffee
and can therefore serve as the primary key. The second column, named SUP_ID , will
hold a number that identifies the coffee supplier; this number will be of SQL type
INTEGER . The third column, called PRICE,
Syntax
CREATE TABLE COFFEES
(COF_NAME VARCHAR(32),
SUP_ID INTEGER,
PRICE FLOAT,
SALES INTEGER,
TOTAL INTEGER)


Example

String createTableCoffees = "CREATE TABLE COFFEES " +
"(COF_NAME VARCHAR(32), SUP_ID INTEGER, PRICE FLOAT, " +
"SALES INTEGER, TOTAL INTEGER)";


Buy It Now

Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: