首页 > 数据库 > > GaussDB 100 类型转换函数T篇中
语法:
TO_CLOB(str)
功能:将入参转换为CLOB类型,str为待转换的类型参数。
示例:
--删除表employee。
DROP TABLE IF EXISTS employee_branch_nanjing;
--创建表employee。
CREATE TABLE employee_branch_nanjing(employee_id INT NOT NULL,first_name VARCHAR(10),last_name VARCHAR(10), hire_date DATETIME,comment VARCHAR(1012));
--新增记录1。
INSERT INTO employee_branch_nanjing(employee_id,first_name,last_name,hire_date,comment) VALUES(1001,'Alice','BROWN','2017-06-20 12:00:00','excellent staff of 2018,bonus 5000¥');
--新增记录2。
INSERT INTO employee_branch_nanjing(employee_id,first_name,last_name,hire_date,comment) VALUES(1002,'BOB','Smith','2017-10-20 12:00:00','excellent manager of 2018,bonus 2000¥');
--新增记录3。
INSERT INTO employee_branch_nanjing(employee_id,first_name,last_name,hire_date,comment) VALUES(1003,'ALAN','Jones','2017-05-10 12:00:00','');
--提交事务。
COMMIT;
--将字段comment的数据转换为CLOB类型。
UPDATE employee_branch_nanjing SET comment=TO_CLOB(comment);
3 rows affected.
语法:
TO_DATE(expr[,fmt])
功能:将expr转换成日期类型。
fmt为转换格式,支持如下:yyyy/mm/dd/hh/hh12/hh24/mi/ss/ff3等。
入参是可转成DATE类型的字符串表达式或者数值类型(隐式转换)。
返回值是DATE。
示例:
SELECT TO_DATE('2018-06-28 13:14:15', 'YYYY-MM-DD HH24:MI:SS:FF') FROM SYS_DUMMY;
TO_DATE('2018-06-28 13:14:15', 'YYYY-MM-DD HH24:MI:SS:FF')
----------------------------------------------------------
2018-06-28 13:14:15
1 rows fetched.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69959250/viewspace-3165402/ ,如需转载,请注明出处,否则将追究法律责任。