有兩種含義的表大小。一種是分配給一個表的物理空間數量,而不管空間是否被使用。可以這樣查詢獲得位元組數:select segment_name, bytes from user_segments where segment_type = 'TABLE'; 或者 Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name另一種表實際使用的空間。這樣查詢:analyze table emp
1.建立一個名為TEST表 2.向TEST表中添加資料INSERT INTO TEST(STUDENT,COURSE,SCORE)select '張三','語文',78 from dual unionselect '張三','數學',87 from dual union select '張三','英語',82 from dual unionselect '張三','物理',90 from dual unionselect '李四','語文',65 from dual unionselect
案例:一個應用表中的一個欄位是主鍵,向表中插入資料時,先把資料放在暫存資料表中(沒有主鍵)然後再插入應用表。這時候如果暫存資料表中有重複資料,無論是主鍵欄位businessid有重複,還是一整行有重複都會報出違反唯一主鍵約束錯誤。方法:group by XX having count(*)>1,rowid,distinct,temporary table,procedure1、查詢表中的重複資料a.重複一個欄位b.重複多個欄位c.重複一整行建立測試表:create table cfa (
V_COUNT INT:=0;V_NUM INT :=0; 1:TBL_MYTABLE 表中要有一個值連續且唯一的列FID BEGIN SELECT COUNT(*) INTO V_COUNT FROM TBL_MYTABLE; SELECT TRUNC(DBMS_RADOM.VALUE(1,V_COUNT+1)) INTO V_NUM FROM DUAL; SELECT * FROM TBL_MYTABLE T WHERE
今天遇到群裡發的一個問題,覺得有點意思,發上來看一下以下代碼在MYSQL中測試通過,MSSQL應該能跑通,未測試。#建立表如下create temporary table tmp (a int, b int ,c int);insert into tmp VALUES (1,10,1),(10,10,2),(10,100,2);#mysql執行select sum(case when c = '1' then A else B end) from tmp#oracle執行select
首先給出一段小程式: 1 set serveroutput on 2 declare 3 maxrecords constant int:=100; 4 i int:=1; 5 begin 6 for i in 1..maxrecords loop 7 insert into testtable(recordnumber,currentdate) 8 values(i,sysdate) 9 end loop;10 dbmps_output.put_line('成功錄入資料');11 comm