Tuesday 23 August 2011

Preparing table for HQL Examples

In this lesson we will create insurance table and populate it with the data.

Preparing table for HQL Examples

In this lesson we will create insurance table and populate it with the data. We will use insurance table for rest of the HQL tutorial.
To create the insurance table and insert the sample data, run the following sql query:


/*Table structure for table `insurance` */



drop table if exists `insurance`;



CREATE TABLE `insurance` (

`ID` int(11) NOT NULL default '0',

`insurance_name` varchar(50) default NULL,

`invested_amount` int(11) default NULL,

`investement_date` datetime default NULL,

PRIMARY KEY (`ID`)

) TYPE=MyISAM;



/*Data for the table `insurance` */





insert into `insurance` values

(1,'Car Insurance',1000,'2005-01-05 00:00:00');

insert into `insurance` values

(2,'Life Insurance',100,'2005-10-01 00:00:00');

insert into `insurance` values

(3,'Life Insurance',500,'2005-10-15 00:00:00');

insert into `insurance` values

(4,'Car Insurance',2500,'2005-01-01 00:00:00');

insert into `insurance` values

(5,'Dental Insurance',500,'2004-01-01 00:00:00');

insert into `insurance` values

(6,'Life Insurance',900,'2003-01-01 00:00:00');

insert into `insurance` values

(7,'Travel Insurance',2000,'2005-02-02 00:00:00');

insert into `insurance` values

(8,'Travel Insurance',600,'2005-03-03 00:00:00');

insert into `insurance` values

(9,'Medical Insurance',700,'2005-04-04 00:00:00');

insert into `insurance` values

(10,'Medical Insurance',900,'2005-03-03 00:00:00');

insert into `insurance` values

(11,'Home Insurance',800,'2005-02-02 00:00:00');

insert into `insurance` values

(12,'Home Insurance',750,'2004-09-09 00:00:00');

insert into `insurance` values

(13,'Motorcycle Insurance',900,

'2004-06-06 00:00:00');

insert into `insurance` values

(14,'Motorcycle Insurance',780

,'2005-03-03 00:00:00');

Above Sql query will create insurance table and add the following data:
















IDinsurance_nameinvested_amountinvestement_date
1Car Insurance10002005-01-05 00:00:00
2Life Insurance1002005-10-01 00:00:00
3Life Insurance5002005-10-15 00:00:00
4Car Insurance25002005-01-01 00:00:00
5Dental Insurance5002004-01-01 00:00:00
6Life Insurance9002003-01-01 00:00:00
7Travel Insurance20002005-02-02 00:00:00
8Travel Insurance6002005-03-03 00:00:00
9Medical Insurance7002005-04-04 00:00:00
10Medical Insurance9002005-03-03 00:00:00
11Home Insurance8002005-02-02 00:00:00
12Home Insurance7502004-09-09 00:00:00
13Motorcycle Insurance9002004-06-06 00:00:00
14Motorcycle Insurance7802005-03-03 00:00:00
In the future lessons we will use this table to write different HQL examples

No comments:

Post a Comment