⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ieptests.sql

📁 derby database source code.good for you.
💻 SQL
📖 第 1 页 / 共 2 页
字号:
--table used for exportcreate table ex_emp(id int , name char(7) , skills varchar(200), salary decimal(10,2)) ;--table used for importcreate table imp_emp(id int , name char(7), skills varchar(200), salary decimal(10,2)) ;--After an export from ex_emp and import to imp_emp both tables should have --same data.--double delimter cases with default character delimter "--field seperator character inside a double delimited string as first lineinsert into ex_emp values(99, 'smith' , 'tennis"p,l,ayer"', 190.55) ;-- Perform Export:call SYSCS_UTIL.SYSCS_EXPORT_TABLE (null, 'EX_EMP' , 'extinout/emp.dat' ,                                  null, null, null) ;-- Perform Importcall SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'IMP_EMP' , 'extinout/emp.dat' ,                                       null, null, null, 0) ;insert into ex_emp values(100, 'smith' , 'tennis"player"', 190.55) ;insert into ex_emp values(101, 'smith' , 'tennis"player', 190.55) ;insert into ex_emp values(102, 'smith' , '"tennis"player', 190.55) ;insert into ex_emp values(103, 'smith' , '"tennis"player"', 190.55) ;insert into ex_emp values(104, 'smith' , '"tennis"""""""""""""""""""""""""""""""""""""player"', null) ;--empty stringinsert into ex_emp values(105, 'smith' , '""', 190.55) ;--just delimeter inside insert into ex_emp values(106, 'smith' , '"""""""""""""""""""', 190.55); --null valueinsert into ex_emp values(107, 'smith"' , null, 190.55) ;--all values are nullsinsert into ex_emp values(108, null , null, null) ;-- Perform Export:call SYSCS_UTIL.SYSCS_EXPORT_TABLE (null, 'EX_EMP' , 'extinout/emp.dat' ,                                  null, null, null) ;-- Perform Importcall SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'IMP_EMP' , 'extinout/emp.dat' ,                                       null, null, null, 0) ;select * from ex_emp;select * from imp_emp;--checking queryselect count(*) from imp_emp, ex_emp      where ex_emp.id = imp_emp.id and      (ex_emp.skills=imp_emp.skills or      (ex_emp.skills is NULL and imp_emp.skills is NULL));delete from imp_emp where id < 105;--export from ex_emp using the a query only rows that got deleted in imp_emp call SYSCS_UTIL.SYSCS_EXPORT_QUERY('select * from ex_emp where id < 105',                                     'extinout/emp.dat' , null, null, null) ;call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'IMP_EMP' , 'extinout/emp.dat' ,                                       null, null, null, 0) ;--checking queryselect count(*) from imp_emp, ex_emp      where ex_emp.id = imp_emp.id and      (ex_emp.skills=imp_emp.skills or      (ex_emp.skills is NULL and imp_emp.skills is NULL));--export the columns in different column order than in the table.call SYSCS_UTIL.SYSCS_EXPORT_QUERY('select name , salary , skills, id from ex_emp where id < 105',                                     'extinout/emp.dat' , null, null, null) ;-- import them in to a with order different than in the table;call SYSCS_UTIL.SYSCS_IMPORT_DATA(null, 'IMP_EMP' ,'NAME, SALARY, SKILLS, ID', null,                                    'extinout/emp.dat', null, null, null, 1) ;--check queryselect count(*) from imp_emp, ex_emp      where ex_emp.id = imp_emp.id and      (ex_emp.skills=imp_emp.skills or      (ex_emp.skills is NULL and imp_emp.skills is NULL));-- do import replace into the table with table order but using column indexescall SYSCS_UTIL.SYSCS_IMPORT_DATA(null, 'IMP_EMP' ,null, '4, 1, 3, 2',                                    'extinout/emp.dat', null, null, null, 1) ;--check queryselect count(*) from imp_emp, ex_emp      where ex_emp.id = imp_emp.id and      (ex_emp.skills=imp_emp.skills or      (ex_emp.skills is NULL and imp_emp.skills is NULL));--replace using insert column names and column indexescall SYSCS_UTIL.SYSCS_IMPORT_DATA(null, 'IMP_EMP' ,'SALARY, ID, SKILLS, NAME', '2, 4, 3, 1',                                    'extinout/emp.dat', null, null, null, 1) ;--check queryselect count(*) from imp_emp, ex_emp      where ex_emp.id = imp_emp.id and      (ex_emp.skills=imp_emp.skills or      (ex_emp.skills is NULL and imp_emp.skills is NULL));---testing with different delimiters-- single quote(') as character delimitercall SYSCS_UTIL.SYSCS_EXPORT_TABLE (null, 'EX_EMP' , 'extinout/emp.dat' ,                                     null, '''', null) ;call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'IMP_EMP' , 'extinout/emp.dat' ,                                     null, '''', null, 1) ;select * from imp_emp ;-- single quote(') as column delimitercall SYSCS_UTIL.SYSCS_EXPORT_TABLE (null, 'EX_EMP' , 'extinout/emp.dat' ,                                     '''',null, null) ;delete from imp_emp ;call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'IMP_EMP' , 'extinout/emp.dat' ,                                     '''', null, null, 0) ;select * from imp_emp;call SYSCS_UTIL.SYSCS_EXPORT_TABLE (null, 'EX_EMP' , 'extinout/emp.dat' ,                                  '*', '%', null) ;call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'EX_EMP' , 'extinout/emp.dat' ,                                  '*', '%', null, 1) ;select * from imp_emp ;--cases for identity columns--create table emp1(id int generated always as identity (start with 100), name char(7), --              skills varchar(200), salary decimal(10,2),skills varchar(200));--check import export with real and double that can not be explictitly--casted from VARCHAR type .create table noncast(c1 double , c2 real ) ;insert into noncast values(1.5 , 6.7 ) ;insert into noncast values(2.5 , 8.999) ;call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('APP' , 'NONCAST' , 'extinout/noncast.dat'  , null , null , null) ;call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'NONCAST' , 'extinout/noncast.dat'  , null , null , null , 0) ;call SYSCS_UTIL.SYSCS_IMPORT_DATA(null, 'NONCAST', 'C2 , C1' , '2, 1' ,                                    'extinout/noncast.dat'  , null , null , null , 0) ;select * from noncast ;--check import/export of time typesCREATE TABLE   TTYPES(DATETYPE DATE, TIMETYPE TIME, TSTAMPTYPE TIMESTAMP );insert into ttypes values('1999-09-09' , '12:15:19' , '1999-09-09 11:11:11' );insert into ttypes values('2999-12-01' , '13:16:10' , '2999-09-09 11:12:11' );insert into ttypes values('3000-11-02' , '14:17:21' , '4999-09-09 11:13:11' );insert into ttypes values('2004-04-03' , '15:18:31' , '2004-09-09 11:14:11' );insert into ttypes values(null , null , null);call SYSCS_UTIL.SYSCS_EXPORT_TABLE (null, 'TTYPES' , 'extinout/ttypes.del' ,                                  null, null, null) ;call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'TTYPES' , 'extinout/ttypes.del' ,                                  null, null, null, 0) ;select * from ttypes;---Import should commit on success and rollback on any failuresautocommit off ;create table t1(a int ) ;insert into t1 values(1) ;insert into t1 values(2) ;call SYSCS_UTIL.SYSCS_EXPORT_TABLE (null, 'T1' , 'extinout/t1.del' ,                                  null, null, null) ;call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'T1' , 'extinout/t1.del' ,                                  null, null, null, 0) ;--above import should have committed , following rollback should be a noop.rollback;select * from t1;insert into t1 values(3) ;insert into t1 values(4) ;--file not found error should rollback call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'T1' , 'extinout/nofile.del' ,                                  null, null, null, 0) ;commit;select * from t1 ;insert into t1 values(3) ;insert into t1 values(4) ;--table not found error should issue a implicit rollback call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'NOTABLE' , 'extinout/t1.del' ,                                  null, null, null, 0) ;commit ;select * from t1 ;delete from t1;---check commit/rollback with replace options using insert into t1 values(1) ;insert into t1 values(2) ;call SYSCS_UTIL.SYSCS_EXPORT_TABLE (null, 'T1' , 'extinout/t1.del' ,                                  null, null, null) ;--above export should have a commit.rollback below should be a nooprollback;select * from t1;call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'T1' , 'extinout/t1.del' ,                                  null, null, null, 1) ;--above import should have committed , following rollback should be a noop.rollback;select * from t1;insert into t1 values(3) ;insert into t1 values(4) ;--file not found error should rollback call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'T1' , 'extinout/nofile.del' ,                                  null, null, null, 1) ;commit;select * from t1 ;insert into t1 values(3) ;insert into t1 values(4) ;--table not found error should issue a implicit rollback call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'NOTABLE' , 'extinout/t1.del' ,                                  null, null, null, 1) ;commit ;---check IMPORT_DATA calls commit/rollbackselect * from t1 ;delete from t1;---check commit/rollback with replace options using insert into t1 values(1) ;insert into t1 values(2) ;call SYSCS_UTIL.SYSCS_EXPORT_TABLE (null, 'T1' , 'extinout/t1.del' ,                                  null, null, null) ;call SYSCS_UTIL.SYSCS_IMPORT_DATA(null, 'T1' , 'A' , '1' , 'extinout/t1.del' ,                                  null, null, null, 0) ;--above import should have committed , following rollback should be a noop.rollback;select * from t1;insert into t1 values(3) ;insert into t1 values(4) ;--file not found error should rollback call SYSCS_UTIL.SYSCS_IMPORT_DATA(null, 'T1', 'A' , '1'  , 'extinout/nofile.del' ,                                  null, null, null, 0) ;commit;select * from t1 ;insert into t1 values(3) ;insert into t1 values(4) ;--table not found error should issue a implicit rollback call SYSCS_UTIL.SYSCS_IMPORT_DATA(null, 'NOTABLE' , 'A' , '1', 'extinout/t1.del' ,                                  null, null, null, 1) ;commit ;select * from t1 ;autocommit on ;--make sure commit import code is ok in autcommit mode.insert into t1 values(3) ;insert into t1 values(4) ;call SYSCS_UTIL.SYSCS_IMPORT_DATA(null, 'T1' , 'A' , '1' , 'extinout/t1.del' ,                                  null, null, null, 0) ;select * from t1 ;insert into t1 values(5) ;insert into t1 values(6) ;--following import will back , but should not have any impact on insertscall SYSCS_UTIL.SYSCS_IMPORT_DATA(null, 'T1', 'A' , '1'  , 'extinout/nofile.del' ,                                  null, null, null, 0) ;select * from t1 ;--END IMPORT COMMIT/ROLLBACK TESTSING---all types supported by Derby import/export

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -