oracle自动段管理ASSM笔记
CREATE TABLESPACE demo DATAFILE 'J:\app\wufan\oradata\orcl\demo01.dbf' SIZE 50M EXTENT MANAGEMENT LOCAL --一定是本地管理 SEGMENT SPACE MANAGEMENT AUTO; --ASSM管理的标志 CREATE TABLE demotab (x NUMBER) TABLESPACE demo STORAGE (INITIAL 1000
CREATE TABLESPACE demoDATAFILE 'J:\app\wufan\oradata\orcl\demo01.dbf'
SIZE 50M
EXTENT MANAGEMENT LOCAL --一定是本地管理
SEGMENT SPACE MANAGEMENT AUTO; --ASSM管理的标志
CREATE TABLE demotab (x NUMBER)
TABLESPACE demo
STORAGE (INITIAL 1000 K); SQL> show user
USER is "SCOTT"
SQL> SELECT t.table_name,
2 t.initial_extent,
3 t.next_extent,
4 t.pct_free,
5 t.pct_used
6 FROM user_tables t
7 WHERE t.table_name = 'DEMOTAB';
TABLE_NAME INITIAL_EXTENT NEXT_EXTENT PCT_FREE PCT_USED
------------------------------ -------------- ----------- ---------- ----------
DEMOTAB 1024000 10
SQL> set serveroutput on
SQL> exec scott.show_space('demotab','auto','T','Y');
Total Blocks............................0
Total Bytes.............................0
Unused Blocks...........................0
Unused Bytes............................0
Last Used Ext FileId....................0
Last Used Ext BlockId...................0
Last Used Block.........................0
*************************************************
The segment is analyzed
0% -- 25% free space blocks.............0
0% -- 25% free space bytes..............0
25% -- 50% free space blocks............0
25% -- 50% free space bytes.............0
50% -- 75% free space blocks............0
50% -- 75% free space bytes.............0
75% -- 100% free space blocks...........0
75% -- 100% free space bytes............0
Unused Blocks...........................0
Unused Bytes............................0
Total Blocks............................0
Total bytes.............................0
PL/SQL procedure successfully completed.
SQL> SELECT t.segment_name, t.extent_id, t.block_id
2 FROM dba_extents t
3 WHERE t.segment_name = 'DEMOTAB';
no rows selected
SQL>
该实验刚好佐证了11g创建一个表,只是产生了一个表定义,并未分配任何空间
附show_space过程代码,觉得这段代码挺有用,记下来mark 一下:
CREATE OR REPLACE PROCEDURE show_space (p_segname_1 IN varchar2, p_space IN varchar2 DEFAULT 'MANUAL' , p_type_1 IN varchar2 DEFAULT 'TABLE' , p_analyzed IN varchar2 DEFAULT 'N' , p_owner_1 IN varchar2 DEFAULT USER ) AS p_segname VARCHAR2 (100); p_type VARCHAR2 (10); p_owner VARCHAR2 (30); l_unformatted_blocks NUMBER; l_unformatted_bytes NUMBER; l_fs1_blocks NUMBER; l_fs1_bytes NUMBER; l_fs2_blocks NUMBER; l_fs2_bytes NUMBER; l_fs3_blocks NUMBER; l_fs3_bytes NUMBER; l_fs4_blocks NUMBER; l_fs4_bytes NUMBER; l_full_blocks NUMBER; l_full_bytes NUMBER; l_free_blks NUMBER; l_total_blocks NUMBER; l_total_bytes NUMBER; l_unused_blocks NUMBER; l_unused_bytes NUMBER; l_lastusedextfileid NUMBER; l_lastusedextblockid NUMBER; l_last_used_block NUMBER; PROCEDURE p (p_label IN varchar2, p_num IN number) IS BEGIN DBMS_OUTPUT.put_line (RPAD (p_label, 40, '.') || p_num); END; BEGIN p_segname := UPPER (p_segname_1); -- rainy changed p_owner := UPPER (p_owner_1); p_type := p_type_1; IF (p_type_1 = 'i' OR p_type_1 = 'I') THEN --rainy changed p_type := 'INDEX'; END IF; IF (p_type_1 = 't' OR p_type_1 = 'T') THEN --rainy changed p_type := 'TABLE'; END IF; IF (p_type_1 = 'c' OR p_type_1 = 'C') THEN --rainy changed p_type := 'CLUSTER'; END IF; DBMS_SPACE.unused_space (segment_owner => p_owner, segment_name => p_segname, segment_type => p_type, total_blocks => l_total_blocks, total_bytes => l_total_bytes, unused_blocks => l_unused_blocks, unused_bytes => l_unused_bytes, last_used_extent_file_id => l_lastusedextfileid, last_used_extent_block_id => l_lastusedextblockid, last_used_block => l_last_used_block ); IF p_space = 'MANUAL' OR (p_space 'auto' AND p_space 'AUTO') THEN DBMS_SPACE.free_blocks (segment_owner => p_owner, segment_name => p_segname, segment_type => p_type, freelist_group_id => 0, free_blks => l_free_blks ); p ('Free Blocks', l_free_blks); END IF; p ('Total Blocks', l_total_blocks); p ('Total Bytes', l_total_bytes); p ('Unused Blocks', l_unused_blocks); p ('Unused Bytes', l_unused_bytes); p ('Last Used Ext FileId', l_lastusedextfileid); p ('Last Used Ext BlockId', l_lastusedextblockid); p ('Last Used Block', l_last_used_block); /*IF the segment is analyzed */ IF p_analyzed = 'Y' THEN DBMS_SPACE.space_usage (segment_owner => p_owner, segment_name => p_segname, segment_type => p_type, unformatted_blocks => l_unformatted_blocks, unformatted_bytes => l_unformatted_bytes, fs1_blocks => l_fs1_blocks, fs1_bytes => l_fs1_bytes, fs2_blocks => l_fs2_blocks, fs2_bytes => l_fs2_bytes, fs3_blocks => l_fs3_blocks, fs3_bytes => l_fs3_bytes, fs4_blocks => l_fs4_blocks, fs4_bytes => l_fs4_bytes, full_blocks => l_full_blocks, full_bytes => l_full_bytes ); DBMS_OUTPUT.put_line (RPAD (' ', 50, '*')); DBMS_OUTPUT.put_line ('The segment is analyzed'); p ('0% -- 25% free space blocks', l_fs1_blocks); p ('0% -- 25% free space bytes', l_fs1_bytes); p ('25% -- 50% free space blocks', l_fs2_blocks); p ('25% -- 50% free space bytes', l_fs2_bytes); p ('50% -- 75% free space blocks', l_fs3_blocks); p ('50% -- 75% free space bytes', l_fs3_bytes); p ('75% -- 100% free space blocks', l_fs4_blocks); p ('75% -- 100% free space bytes', l_fs4_bytes); p ('Unused Blocks', l_unformatted_blocks); p ('Unused Bytes', l_unformatted_bytes); p ('Total Blocks', l_full_blocks); p ('Total bytes', l_full_bytes); END IF; END;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



To query the Oracle tablespace size, follow the following steps: Determine the tablespace name by running the query: SELECT tablespace_name FROM dba_tablespaces; Query the tablespace size by running the query: SELECT sum(bytes) AS total_size, sum(bytes_free) AS available_space, sum(bytes) - sum(bytes_free) AS used_space FROM dba_data_files WHERE tablespace_

Oracle View Encryption allows you to encrypt data in the view, thereby enhancing the security of sensitive information. The steps include: 1) creating the master encryption key (MEk); 2) creating an encrypted view, specifying the view and MEk to be encrypted; 3) authorizing users to access the encrypted view. How encrypted views work: When a user querys for an encrypted view, Oracle uses MEk to decrypt data, ensuring that only authorized users can access readable data.

Data import method: 1. Use the SQLLoader utility: prepare data files, create control files, and run SQLLoader; 2. Use the IMP/EXP tool: export data, import data. Tip: 1. Recommended SQL*Loader for big data sets; 2. The target table should exist and the column definition matches; 3. After importing, data integrity needs to be verified.

Creating an Oracle table involves the following steps: Use the CREATE TABLE syntax to specify table names, column names, data types, constraints, and default values. The table name should be concise and descriptive, and should not exceed 30 characters. The column name should be descriptive, and the data type specifies the data type stored in the column. The NOT NULL constraint ensures that null values are not allowed in the column, and the DEFAULT clause specifies the default values for the column. PRIMARY KEY Constraints to identify the unique record of the table. FOREIGN KEY constraint specifies that the column in the table refers to the primary key in another table. See the creation of the sample table students, which contains primary keys, unique constraints, and default values.

Uninstall method for Oracle installation failure: Close Oracle service, delete Oracle program files and registry keys, uninstall Oracle environment variables, and restart the computer. If the uninstall fails, you can uninstall manually using the Oracle Universal Uninstall Tool.

There are three ways to view instance names in Oracle: use the "sqlplus" and "select instance_name from v$instance;" commands on the command line. Use the "show instance_name;" command in SQL*Plus. Check environment variables (ORACLE_SID on Linux) through the operating system's Task Manager, Oracle Enterprise Manager, or through the operating system.

There are the following methods to get time in Oracle: CURRENT_TIMESTAMP: Returns the current system time, accurate to seconds. SYSTIMESTAMP: More accurate than CURRENT_TIMESTAMP, to nanoseconds. SYSDATE: Returns the current system date, excluding the time part. TO_CHAR(SYSDATE, 'YYY-MM-DD HH24:MI:SS'): Converts the current system date and time to a specific format. EXTRACT: Extracts a specific part from a time value, such as a year, month, or hour.

An AWR report is a report that displays database performance and activity snapshots. The interpretation steps include: identifying the date and time of the activity snapshot. View an overview of activities and resource consumption. Analyze session activities to find session types, resource consumption, and waiting events. Find potential performance bottlenecks such as slow SQL statements, resource contention, and I/O issues. View waiting events, identify and resolve them for performance. Analyze latch and memory usage patterns to identify memory issues that are causing performance issues.
