mysql怎么把字段名变成中文

mysql怎么把字段名变成中文,第1张

1、创建测试表,

create table test_zw(id number, v_date date)

2、插入测试数据

insert into test_zw values(1,20190101)

insert into test_zw values(2,20190102)

insert into test_zw values(3,20190103)

insert into test_zw values(4,20190104)

3、查询表中记录,select t.* from test_zw t

4、编写sql,将v_date字段翻译为中文'日期',select t.*, V_DATE AS '日期' from test_zw t

oracle的是这样的:

Oracle数据库中向BLOB类型字段插入字符串并把插入的BLOB数据转换成字符串显示的方法

首先先在数据库中创建一张表

create table TB_TEST

(

ID NUMBER,

BLB BLOB

)

其次向表中插入一条空数据

insert into tb_test (id,blb) values (1,empty_blob())

最后更改BLOB字段的值

declare

directions BLOB

amount BINARY_INTEGER

offset INTEGER

first_direction VARCHAR2(100)

more_directions VARCHAR2(500)

begin

update set blb = empty_blob() where id = 1--更新和新增一样要将BLOB字段设置为EMPTY_BLOB()

select blb into directions from tb_test where id = 1 for update--一定要用for update锁住记录,否则

--DBMS_LOB.OPEN会出错

DBMS_LOB.OPEN(directions, DBMS_LOB.LOB_READWRITE)

first_direction := '这是我的第一个插入blob的数据,测试一下看一下效果如何,是否能够用pl/sql直接插到插入的数据值!'

amount := LENGTHB(first_direction)--number of characters to write

--有中文必须用LENGTHB

offset := 1--begin writing to the first character of the CLOB

DBMS_LOB.WRITE(directions,

amount,

offset,

UTL_RAW.cast_to_raw(first_direction))

--UTL_RAW.cast_to_raw函数将字符串转换成二进制数

DBMS_LOB.CLOSE(directions)

commit

end

把插入的BLOB数据转换成字符串显示的方式是

select id,UTL_RAW.cast_to_varchar2(blb) blb from tb_test t

这种方式在显示纯文本字符串时显示的是正常的,可当我插入的数据例如是<form id="form1" name="form1"><input type="data" value="hello"></form>这种时在查询显示时就会显示为空。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/7443387.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-05
下一篇 2023-04-05

发表评论

登录后才能评论

评论列表(0条)

保存