search
HomeDatabaseMysql Tutorialoracle自动段管理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 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 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;

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Explain the InnoDB Buffer Pool and its importance for performance.Explain the InnoDB Buffer Pool and its importance for performance.Apr 19, 2025 am 12:24 AM

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

MySQL vs. Other Programming Languages: A ComparisonMySQL vs. Other Programming Languages: A ComparisonApr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Learning MySQL: A Step-by-Step Guide for New UsersLearning MySQL: A Step-by-Step Guide for New UsersApr 19, 2025 am 12:19 AM

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL: Essential Skills for Beginners to MasterMySQL: Essential Skills for Beginners to MasterApr 18, 2025 am 12:24 AM

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL: Structured Data and Relational DatabasesMySQL: Structured Data and Relational DatabasesApr 18, 2025 am 12:22 AM

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL: Key Features and Capabilities ExplainedMySQL: Key Features and Capabilities ExplainedApr 18, 2025 am 12:17 AM

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

The Purpose of SQL: Interacting with MySQL DatabasesThe Purpose of SQL: Interacting with MySQL DatabasesApr 18, 2025 am 12:12 AM

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

MySQL for Beginners: Getting Started with Database ManagementMySQL for Beginners: Getting Started with Database ManagementApr 18, 2025 am 12:10 AM

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools