create or replace function long_to_char(utable in varchar2,uid in number)return varchar2
as uval varchar2(32767);
begin
select data_default into uval from user_tab_cols where table_name = upper(utable) and column_id = uid;
uval := substr(uval,1,50);
return uval;
end long_to_char;
建立了以後,就可以呼叫之了
--在第一行和最後一行改表名 查詢表結構select 'tablea' as 表名, a.column_name as 字段,
case
when a.data_type = 'number' and a.data_precision is null and a.data_scale = 0 then
'integer'
when a.data_type = 'timestamp(6)'then
'timestamp'
else
a.data_type
end as 資料型別,
case
when a.data_type in ('char','nchar') then
to_char(a.char_col_decl_length)
when a.data_type in ('varchar2','nvarchar2','raw','urowid') then
to_char(a.char_length)
when a.data_type = 'float' then
to_char(a.data_precision)
when a.data_type = 'number' and a.data_precision is null and a.data_scale = 0 then
''when a.data_type = 'number' and a.data_scale = 0 then
to_char(a.data_precision)
when a.data_type = 'number' and a.data_scale != 0 then
to_char(a.data_precision || ',' || a.data_scale)
when a.data_type = 'timestamp(6)' then
'6'else
''end as 長度,
decode(a.nullable,'y',null,'n','n') as 可為空,
long_to_char(a.table_name,a.column_id) as 預設值,
b.comments as 備註
from sys.user_tab_cols a
left join sys.user_col_comments b on a.table_name = b.table_name
and a.column_name = b.column_name
where a.table_name = 'tablea'
order by a.table_name, a.column_id
一段時間後,又發現了新問題,我想獲得user_constraints表中的search_condition資訊,但這是檢視中的乙個字段,不能使用上面呼叫的方法
於是重新寫了乙個
createorreplace
function search_cond( p_cons_name in
varchar2 ) return
varchar2
asl_search_condition
varchar2(4000
);begin
select search_condition into
l_search_condition
from
user_constraints
where constraint_name =
p_cons_name;
return
l_search_condition;
end;
後端傳Long型別資料精度問題
在今天編碼過程中發現乙個小問題。後端資料庫資料 1169459812992421888 前台拿到 1169459812992422000 前幾位高度重合,排除程式邏輯問題。在返回前設定斷點列印,資料依據與資料庫依舊保持一致 說明資料是在返回過程中丟失了精度。考慮不直接傳long,傳json 引入依賴...
Oracle中的long型別
1 long 資料型別中儲存的是可變長字串,最大長度限制是2gb。2 對於超出一定長度的文字,基本只能用long型別來儲存,資料字典中很多物件的定義就是用long來儲存的。3 long型別主要用於不需要作字串搜尋的長串資料,如果要進行字元搜尋就要用varchar2型別。4 很多任務具,包括sql p...
Long型別精度丟失問題
js long型別經度丟失 解決方案 後端將long型別引數轉為字串後返回給前端 在單個long型別的引數上加上 import com.fasterxml.jackson.databind.annotation.jsonserialize jsonserialize using tostringse...