replace(string,from_str,to_str) 即:將string中所有出現的from_str替換為to_str。
三個引數可以是字元或二進位制資料型別;from_str不能為空字串 ('');不支援 text,ntext型別欄位的替換
如果其中的乙個輸入引數資料型別為 nvarchar,則返回 nvarchar;否則 replace 返回 varchar。
如果任何乙個引數為 null,則返回 null。
查詢
select replace('abcdefg bcd','bcd','***')
select city_name,replace(city_name,'市','') as city from tmp_city
更新update t_risk set file_path = replace (file_path,'webs','web') where file_path is not null;
鎖表
鎖全表:select * from tablename where 1=1 for update
鎖部分行:select * from tablename where 欄位1=引數1 for update
解鎖
--檢視被鎖的表
select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_objects b where b.object_id = a.object_id;
--檢視那個使用者那個程序造成死鎖
select b.username,b.sid,b.serial#,logon_time from v$locked_object a,v$session b where a.session_id = b.sid order by b.logon_time;
--殺鎖
alter system kill session 'sid,serial#';
根據表名查表的索引
select index_name,index_type from user_indexes where table_name='t_mcht_order_pay_serial';
根據索引名查索引詳細資訊
select dbms_lob.substr(dbms_metadata.get_ddl('index','ind_t_mcht_order_pay_serial_id'))from dual;
修改唯一索引
--修改唯一索引
--從biz_type, org_party_no
--變更到biz_type, org_party_no, sub_biz_type
--delete indexes
drop index idx_charge_party_config;
-- create/recreate indexes
create unique index idx_charge_party_config on t_charge_party_config (biz_type, org_party_no, sub_biz_type)
tablespace users
pctfree 10
initrans 2
maxtrans 255
storage
( initial 64k
next 1m
minextents 1
maxextents unlimited
);
modidy修改字段屬性
--單個字段
alter table table_name modify column column_name varchar(255) default '' comment '注釋';
--多個字段
alter table student modify(id number(4),studentname varchar2(100));
如果欄位有資料,且型別不能直接修改,可以先修改原欄位名sub_org為sub_org_copy,新增欄位sub_org(目標型別),把sub_org_copy中的資料轉換複製給sub_org,刪除sub_org_copy
update 表名 set sub_org = cast(sub_org_copy as varchar2(30));
alter新增字段
alter table t_charge_party_config add (sub_org_no varchar2(32));
-- 修改表名
rename table old_table to new_table;
或alter table old_table rename as new_table;
-- 修改列名稱
alter table table_name change column old_name new_name varchar(255);
5、資料型別轉換函式
and to_char(crt_time, 'yyyymmdd') >='20181101'
and crt_time >=to_date('2018-11-01 00:00:00','yyyy-mm-dd hh24:mi:ss')
--檢視資料庫版本
select * from v$version;
7、mysql設定建立時間欄位和更新時間字段自動獲取時間,填充時間
1、引言
在實際開發中,每條資料的建立時間和修改時間,盡量不需要應用程式去記錄,而由資料庫獲取當前時間自動記錄建立時間,獲取當前時間自動記錄修改時間。
2、建立語句
(1)–新增createtime 設定預設時間 current_timestamp
alter table `table_name`
add column `createtime` datetime null default current_timestamp comment '建立時間' ;
(2)–修改createtime 設定預設時間 current_timestamp
alter table `table_name`
modify column `createtime` datetime null default current_timestamp comment '建立時間' ;
(3)–新增updatetime 設定 預設時間 current_timestamp 設定更新時間為 on update current_timestamp
alter table `table_name`
add column `updatetime` timestamp null default current_timestamp on update current_timestamp comment '建立時間' ;
(4)–修改 updatetime 設定 預設時間 current_timestamp 設定更新時間為 on update current_timestamp
alter table `table_name`
modify column `updatetime` timestamp null default current_timestamp on update current_timestamp comment '建立時間' ;
開發環境 測試環境 預生產環境 生產環境區別
環境分以下幾種 1.開發和配置環境 所有的開發和配置在這個環境裡進行。一般情況下,只有這個環境可以改配置和進行開發,並且一般不在這個環境下建立資料。開發環境就是每個開發人員電腦上的開發環境,只有開發人員可以配置和開發,寫資料測試放在測試環境 2.測試環境 3.預生產環境 不是必須的 從生產環境不定期...
開發環境 測試環境 預生產環境 生產環境區別
環境分以下幾種 1.開發和配置環境 所有的開發和配置在這個環境裡進行。一般情況下,只有這個環境可以改配置和進行開發,並且一般不在這個環境下建立資料。開發環境就是每個開發人員電腦上的開發環境,只有開發人員可以配置和開發,寫資料測試放在測試環境 2.測試環境 3.預生產環境 不是必須的 從生產環境不定期...
curl生產環境下常用使用總結
一 除錯介面工具 1 postman 2 postwoman二 小功能除錯curl 2.1 get請求 curl 請求的介面位址 curl 192.168.48.101 8081 api testget 看到詳細的請求資訊則加 v curl 192.168.48.101 8081 api testg...