Getting KingbaseES database, Notes

Recently a project need to use KingbaseES ( gold warehouse database ), then spent half a day to install studied under. Here to talk about the installation and use some attention.

Beginning to use gold warehouse database, said I was "rejected", ha ha ha ha, I wonder what is it? How not heard of it, but there is no way the project is necessary to use this database, it is necessary to study now.


Gold warehouse database download link:

http://www.kingbase.com.cn/kingbase/newslist/list-186-1.html

Please note that the operating system and select the corresponding version of the download.

Installation Instructions link:

http://www.kingbase.com.cn/kingbase/newslist/list-187-1.html


After installation is complete, first try to use the database client to see in the end is how the structure looks like




After the installation is complete is the gold warehouse database that comes with the client management interface. Open the table to find a button to create them, but without looking, can only write sql statement, then use sql statement written statement to create a simple table, then after performing at the table is created in any place and found the default created in the database -> mode -> under PUBLIC this step will know the table is created somewhere and then select the table right to see some of what can be operated. found to be the visualization field, it can only be performed with the sql.

Then try the following table additions and deletions to the investigation statement, found here and the standard sql some small changes here SQL strictly case-sensitive. Also field, table name is necessary to use "(double quotation marks), attention must be double quotes oh , apostrophes or quotation, will not be successfully executed, oh.

demo:

--字段,表名严格区分大小写,写sql时请注意,所有表名前加"PUBLIC",这个是数据库下的一个模式,相当于一个文件夹,我们所有的表都放在这个文件夹下的
--查询语句(字段可以根据自己的实际业务需求增加或者减少,不必要全部查询出来), 查询单个对象到时返回是Object[]数组,到时用下标取值拼装成自己需要的对象
--针对取别名的语法
SELECT t."id" as ids,"bz","cjr","cjsj","scbj","xgr","xgsj","dlyhm","dymm","lxdh","yhjs","zsxm","zw" 
FROM "PUBLIC"."yhb" as t WHERE "dlyhm" like '%z%';


--针对使用case when的语法
SELECT t."id" as ids,"bz","cjr","cjsj",CASE "scbj" WHEN 1 THEN '锁定' ELSE '正常' END as te,"xgr","xgsj","dlyhm","dymm","lxdh","yhjs","zsxm","zw" 
FROM "PUBLIC"."yhb" as t WHERE "id"=5;


--日期格式化 语法
--%M 月名字(January……December) 
--%W 星期名字(Sunday……Saturday) 
--%D 有英语前缀的月份的日期(1st, 2nd, 3rd, 等等。) 
--%Y  年, 数字, 4 位 
--%y  年, 数字, 2 位 
--%a  缩写的星期名字(Sun……Sat)  
--%d  月份中的天数, 数字(00……31)  
--%e  月份中的天数, 数字(0……31)  
--%m  月, 数字(01……12)  
--%c  月, 数字(1……12)  
--%b  缩写的月份名字(Jan……Dec)  
--%j  一年中的天数(001……366)  
--%H  小时(00……23)  
--%k  小时(0……23)  
--%h  小时(01……12)  
--%I  小时(01……12)  
--%l  小时(1……12)  
--%i  分钟, 数字(00……59)  
--%r  时间,12 小时(hh:mm:ss AM/PM)  
--%T  时间,24 小时(hh:mm:ss)  
--%S  秒(00……59)  
--%s  秒(00……59)  
--%p  AM 或 PM  
--%%  一个文字“%”。  
select DATE_FORMAT("xgsj", '%Y-%m-%d %T') from "PUBLIC"."cjpzglb"


--保存语句(字段可以根据自己的实际业务需求增加或者减少,不必要全部插入),传值时varchar类型的需要'单引号
INSERT INTO "PUBLIC"."yhb"
 ("id","scbj","dlyhm")
 VALUES 
 (1,0,'zhangan1');


--修改语句(字段可以根据自己的实际业务需求增加或者减少,不必要全部修改), 删除语句和修改一样,只是把scbj状态改一下
UPDATE "PUBLIC"."yhb"
SET "scbj"='1',"dlyhm"='lisi'
WHERE "id"=5;







After the operation is complete console, now consider java program to connect to the database operations, first with jdbc tried, successfully, the database driver jar package in the lib directory of the installation package, the database can be integrated into hibernate, but it accounted for hql statement did not realize when operating with only execute sql.


These are the first-time use of experience KingbaseES database, there is something wrong we hope the exhibitions. Learn together.



发布了90 篇原创文章 · 获赞 21 · 访问量 47万+

Guess you like

Origin blog.csdn.net/yx13649017813/article/details/47668435