oracle常用的一些sql命令

2022-08-29 09:27:07 字數 1445 閱讀 2049

//檢視系統當前時間   hh24 24小時制  mi是正確的分鐘

select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual

//hh非24   mm不區分大小寫 日期中mm系統認為是月份

select to_char(sysdate,'yyyy-mm-dd hh:mm:ss') from dual

//報告timestamp資料型別格式的系統日期。

select systimestamp from dual; 

//查詢當前登入使用者

select username from user_users

show user

//檢視表結構(字段資料型別)

desc user_users

//查詢當前使用者所擁有的表

select table_name from  user_tables

//忘記密碼登入

開啟cmd視窗,輸入 sqlplus / as sysdba 

//遠端連線

gb/[email protected]/orcl

//建立序列

create sequence 序列名

start with 起始序列

increment by 每次增加的值

序列名.nextval(下乙個序列)

序列名.currval(當前序列)

//建立回話臨時表資料

create global temporary table 表 as 另一張表資料 on commit preserve rows;(可以複製原表中資料,比較常用的就是這個。)

//新增字段注釋(表注釋)

comment on column tmp_xian.id is '主鍵'

comment on column tmp_xian.name is '最大使用者名稱'

comment on table tablename is '使用者表'; 

//varchar2最大長度4000bite   char(2000bite)

//檢視前500行資料

select * from t_pub_download_detail where rownum<500

//count(*) 和count(1) 效率結果都一樣   count(name)統計name列不為空的記錄

select count(*) from table;   count(1)

//date 日期時間(精確到秒)   timestamp(精確到小數秒)

//union 表鏈結(篩選重覆記錄)   union all(簡單的2個表結果合併)   union all效率高

//ltrim(字串):將字串左邊的空格移除。   rtrim(字串): 將字串右邊的空格移除。   trim(字串): 將字串開頭和末尾的空格移除。   alltrim(字串):將字串左右邊兩邊的空格移除。

oracle常用的一些sql命令

檢視系統當前時間 hh24 24小時制 mi是正確的分鐘 select to char sysdate,yyyy mm dd hh24 mi ss from dual hh非24 mm不區分大小寫 日期中mm系統認為是月份 select to char sysdate,yyyy mm dd hh m...

mysql一些命令 mysql常用的一些命令

一 授權登入 參考grant all privileges on cacti.to hnf localhost identified by hnf 2014 只給cacti這個資料庫授權 grant all on to root localhost identified by huningfei 只...

一些常用SQL

1 對select 查詢出來的資料時行修改.1 select t.rowid,t.fromtablename t 取出資料物理rowid 並顯示,些時可以對其進行修改.2 select fromtablenamefor update 取出資料顯示,此時可以對其進行編輯.以上兩種修改,修改後一定要進行...