sql基礎常用函式總結

2021-07-11 20:48:21 字數 1304 閱讀 5688

--查表,*可以替換為table列的名稱,select是對table的篩選,*代表所有列

select * from table

--更新update 表名稱 set 列名稱 = 新值 where 列名稱 = 某值

update table set username='jack'

--刪除

delete from table

--刪除一列

delete from table where username is null

--字串處理

lower()--轉化小寫

select lower(username) from table

intcap--首字母大寫

select initcap(username) from table

--擷取

select substr(username,開始(int),結束(int)) from table

--判斷字串的位置

select instr('被搜尋的字串','希望搜尋到的字串') from table

--字串替換,

select replace(列名,'需替換字段','替換字段') from table

--數字處理

--數字四捨五入

select round(列) from table

--小數截斷

select trunc(列,截斷幾位) from table

--取餘

select mod(列,取餘第幾位) from table

--日期轉化

--to_date()yyyy-mm-dd hh24:mi:ss日期格式根據需求的修改

--字串處理函式 to_char(),to_numbe()r,to_date()

--to_char用法如圖

oracle常用sql及函式總結

一.dao層入庫到資料庫系統和當前時間不一致的問題 to char sysdate,yyyy mm dd hh24 mi ss 總結 yyyy 表示 年份,mm 表示 月份,dd 表示 天,hh24 表示 小時,mi 表示 分鐘 ss 表示 秒,to char sysdate,yyyy mm dd ...

SQL中的常用函式總結

總結下sql的常用函式,從開博開始,用到乙個總結乙個,方便以後複習。為了方便,有些直接就從其他部落格複製過來。1 stuff函式 對stuff函式功能進行分析 stuff expression1 str,startindex,lengthint,expression2 str 函式共有四個引數,其功...

常用sql總結

1 查詢表名 select table name from user tables where table name like spm or table name like os 2 比對 兩個使用者中的表的字段,長度,注釋等的差異 在plsql中 tools compare user object...