当前位置: 代码迷 >> SQL >> 精典sql小结
  详细解决方案

精典sql小结

热度:19   发布时间:2016-05-05 14:37:45.0
精典sql总结

--删除表中的重复记录
DELETE FROM table_name a
????? WHERE ROWID >
?????????????? (SELECT MIN (ROWID)
????????????????? FROM table_name b
???????????????? WHERE b.pk_column_1 = a.pk_column_1
?????????????????? AND b.pk_column_2 = a.pk_column_2);

?

?

2. 查找表空间datafile
SQL>select * from dba_data_files where tablespace_name = ‘UNDOTBS1′;

?

?

3.查看表空占用情况

?

?SELECT UPPER(F.TABLESPACE_NAME) "表空间名",D.TOT_GROOTTE_MB "表空间大小(M)",??????   D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)",
??????   TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) /?? D.TOT_GROOTTE_MB * 100,   2),'990.99') "使用比",???   F.TOTAL_BYTES "空闲空间(M)",??????   F.MAX_BYTES "最大块(M)"  
 FROM (SELECT TABLESPACE_NAME, ROUND(SUM(BYTES) / (1024 * 1024),? 2) TOTAL_BYTES,   ROUND(MAX(BYTES) /???????????? (1024 * 1024),?? 2) MAX_BYTES  ????  FROM SYS.DBA_FREE_SPACE   GROUP BY TABLESPACE_NAME) F,
?? (SELECT DD.TABLESPACE_NAME,ROUND(SUM(DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB   FROM SYS.DBA_DATA_FILES DD   GROUP BY DD.TABLESPACE_NAME) D   WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME   ORDER BY 4 DESC

?

?

?

http://blog.chinabyte.com/a/578694.html?

  相关解决方案