alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

HSQLDB example source code file (TestSelfVerify.txt)

This example HSQLDB source code file (TestSelfVerify.txt) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - HSQLDB tags/keywords

app2, correct, db, insert, insert, into, into, this, value, value, values, values

The HSQLDB TestSelfVerify.txt source code

--
-- TestSelfVerify.txt
--
-- This is part of a three part suite of scripts to test persistence in the same DB

-- Correct handling of index creation for foreign keys
-- check the consistency of foreign keys and primary keys
/*e*/create table VEREIN(VCODE CHAR(10) not null);
/*e*/create unique index VEREIN_PK on VEREIN (VCODE);
/*e*/create table BEWERB(VCODE CHAR(10) not null, ID SMALLINT not null);
/*e*/create unique index BEWERB_FK2 on BEWERB(ID);
/*e*/create unique index BEWERB_FK1 on BEWERB(VCODE);
/*e*/alter table BEWERB add constraint bv foreign key (VCODE) references VEREIN (VCODE);

-- null value in not null column
/*e*/insert into verein values (null);
-- referential no matching row
/*e*/insert into bewerb values ('aaaaaaa',18);
-- duplicate row
/*e*/insert into bewerb values ('hijklmn',7);
-- referential integrity row has reference
/*e*/delete from verein where vcode='opqrstu'

--test identity increment
INSERT INTO APP2 (VALUE) VALUES(13);
INSERT INTO APP2 (VALUE) VALUES(14);

/*r5,14*/ SELECT COUNT(ID), MAX(VALUE) FROM APP2

--test persistence of insert into operations
/*c2*/SELECT * FROM NEWAPP WHERE APP_NAME = 'Eran';
/*c2*/SELECT * FROM NEWAPP WHERE APP_NAME = 'Shelly';
/*c4*/SELECT * FROM NEWAPP;

--test correct persistent of view defined in TestSelfCreate.txt
/*r
  14,newdir,NULL
*/select * from "View"

/*r
  14,newdir,NULL
*/select * from "View2"

--test INSERT .. INTO and indexes
select * into cached bewerb_copy from bewerb;
create index idx_bewerb_copy on bewerb_copy(VCODE,ID);

/*u0*/SHUTDOWN;

Other HSQLDB examples (source code examples)

Here is a short list of links related to this HSQLDB TestSelfVerify.txt source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.