建表语句: create table ttimestamp(a timestamp default '2014-01-01 12:25:36' ,b int); 数据文件: 2014-01-01 12:01:01|1 |2 |3 |4 |5 2014-01-02 12:03:03|6 加载过程: gbase> LOAD DATA INFILE 'http://10.10.120.226/timestamp.txt' INTO TABLE test.ttime stamp DATA_FORMAT 3 FIELDS TERMINATED BY '|' TIMESTAMP FORMAT '%Y-%m-%d %H:%i:%s'; Query OK, 6 rows affected Task 2 finished, Loaded 6 records, Skipped 0 records 查询入库数据: gbase> select * from ttimestamp order by b +---------------------+------+ | a | b | +---------------------+------+ | 2014-01-01 12:01:01 | 1 | | 2014-01-01 12:25:36 | 2 | | 2014-01-01 12:25:36 | 3 | | 2014-01-01 12:25:36 | 4 | | 2014-01-01 12:25:36 | 5 | | 2014-01-02 12:03:03 | 6 | +---------------------+------+
字符串由零个或多个字符组成的序列,用单引号括起来,可以参照GBase8s语法。全 部除空字符串('')外的字符串文本具有数据类型CHAR。 'Hello, world!' 'XYZ Corporation' '10-NOV-91' 'He said "Life is like licking honey from a thorn."' '$1,000,000' PL/SQL在字符串变量中区分大小写。例如,'baker'和'Baker'不同的。 要表示字符串中的撇号,可以写两个单引号,即不等于写双引号: 'I''m a string, you''re a string.'
// ----------- if (args.length == 0) { System.out.println("\n***ERROR: connection URL must be provided " + "in order to run the demo!"); return; } url = args[0];
System.out.println("\n***ERROR: " + e.getMessage()); e.printStackTrace(); return; } // ------------------- // Setup UDT meta data // ------------------- UDTMetaData mdata = null; try { mdata = new UDTMetaData(); System.out.print("Setting fields in mdata..."); mdata.setSQLName("acircle"); mdata.setLength(24); mdata.setFieldCount(3); mdata.setFieldName(1, "x"); mdata.setFieldName(2, "y"); mdata.setFieldName(3, "radius"); mdata.setFieldType(1, com.gbasedbt.lang.IfxTypes.IFX_TYPE_INT); mdata.setFieldType(2, com.gbasedbt.lang.IfxTypes.IFX_TYPE_INT); mdata.setFieldType(3, com.gbasedbt.lang.IfxTypes.IFX_TYPE_INT); // set class name if don't want to use the default name // .class mdata.setClassName("ACircle"); mdata.setJarFileSQLName("ACircleJar"); mdata.keepJavaFile(true); System.out.println("ok"); } catch (SQLException e) { System.out.println("***ERROR: " + e.getMessage()); return; }
// -------------------------------------------------------- // create java file for UDT and install UDT in the database // --------------------------------------------------------
GBase 8s JDBC Driver 程序员指南 南大通用数据技术股份有限公司 - 210 -
UDTManager udtmgr = null; try { udtmgr = new UDTManager(conn);