{"id":160,"date":"2008-09-28T21:07:00","date_gmt":"2008-09-28T19:07:00","guid":{"rendered":"http:\/\/antynet.pl\/index.php\/2008\/09\/28\/oracle-tablespaces\/"},"modified":"2010-08-24T23:52:25","modified_gmt":"2010-08-24T21:52:25","slug":"oracle-tablespaces","status":"publish","type":"post","link":"https:\/\/www.antynet.pl\/index.php\/2008\/09\/28\/oracle-tablespaces\/","title":{"rendered":"ORACLE TABLESPACES"},"content":{"rendered":"<p><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">check space:<br \/><\/span>SELECT tablespace_name,sum(bytes)\/1024\/1024 MB FROM dba_data_files GROUP BY tablespace_name ORDER by 1;<\/span><br \/><span style=\"font-family: arial;\">SELECT tablespace_name,sum(bytes)\/1024\/1024 MB,sum(maxbytes)\/1024\/1024 maxbytes_MB FROM dba_data_files GROUP BY tablespace_name,maxbytes ORDER by 1;<\/span><br \/><span style=\"font-family: arial;\">SELECT tablespace_name,file_name,bytes\/1024\/1024 use_MB,maxbytes\/1024\/1024 max_MB,(maxbytes-bytes)\/1024\/1024 left_MB FROM dba_data_files WHERE maxbytes <span>0&nbsp; ORDER by 1;<\/span><br \/><span style=\"font-family: arial;\">SELECTtablespace_name,sum(bytes)\/1024\/1024 MB FROM dba_free_space GROUP BY tablespace_name;<span style=\"font-weight: bold;\"><br \/>switch mode:<\/span><br \/>ALTER TABLESPACE  [ts] ONLINE|OFFLINE;<br \/><span style=\"font-weight: bold;\">prepare files to copy:<br \/><\/span>ALTER TABLESPACE  [ts] BEGIN|END BACKUP;<br \/><span style=\"font-weight: bold;\">change file name:<\/span><br \/><\/span><\/p>\n<ol style=\"font-family: arial;\">\n<li>ALTER TABLESPACE  [ts] OFFLINE;<\/li>\n<li>skopiowanie pliku przestrzeni do innej lokalizacji,<\/li>\n<li>ALTER TABLESPACE  [ts] RENAME DATAFILE '[old_file]&#8217; TO &#8217;<new_file>[new_file]&#8217;;<\/new_file><\/li>\n<li>ALTER TABLESPACE  [ts] ONLINE;<\/li>\n<li>usuni\u0119cie starego<span style=\"font-weight: bold;\"> <\/span>pliku<\/li>\n<\/ol>\n<p><span style=\"font-family: arial; font-weight: bold;\">change ts name:<\/span><br \/><span style=\"font-family: arial;\">ALTER TABLESPACE  [old_ts] RENAME TO [new_ts];<br \/><\/span><span style=\"font-weight: bold;\">add new file to ts:<\/span><br \/>ALTER TABLESPACE  [ts] ADD DATAFILE '[file]&#8217; size [size]M AUTOEXTEND ON NEXT [size]<size>M MAXSIZE UNLIMITED;<\/size><br \/><size><b>TEMP<\/b><br \/><\/size><br \/><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">check TEMP ts:<br \/><\/span>SELECT * FROM dba_temp_files;<br \/><\/span><span style=\"font-family: arial;\">SELECT * FROM database_properties WHERE property_name = 'DEFAULT_TEMP_TABLESPACE&#8217;;<br \/><\/span><span style=\"font-weight: bold;\">create TEMP ts:<\/span><br \/><span style=\"font-family: arial;\">CREATE TEMPORARY TABLESPACE  [ts] TEMPFILE '[file]&#8217; SIZE [size]M AUTOEXTEND ON MAXSIZE [size]M;<br \/><span style=\"font-weight: bold;\">add new file to TEMP ts:<\/span><br \/>ALTER TABLESPACE [ts] ADD TEMPFILE '[file]&#8217; SIZE [size]M<br \/><span style=\"font-weight: bold;\">set TEMP ts:<\/span><br \/><\/span><span style=\"font-family: arial;\">ALTER USER  [user] DEFAULT TABLESPACE  [ts] TEMPORARY TABLESPACE [ts];<\/span><br \/><span style=\"font-family: arial;\">ALTER DATABASE DEFAULT TEMPORARY TABLESPACE [ts];<br \/><span style=\"font-weight: bold;\">remove TEMP ts:<\/span><br \/>ALTER DATABASE TEMPFILE [nr] OFFLINE;<br \/>ALTER DATABASE TEMPFILE [nr] DROP;<br \/><span style=\"font-weight: bold;\">check load TEMP ts<\/span>:<br \/>SELECT tablespace_name, bytes_used, bytes_free FROM v$temp_space_header;<br \/><span style=\"font-weight: bold;\">&nbsp;<\/span><\/span><br \/><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">remove ts<\/span>:<br \/>DROP TABLESPACE  [ts] INCLUDING CONTENTS AND DATAFILES;<br \/><span style=\"font-weight: bold;\">check segments from ts<\/span>:<br \/>SELECT segment_name,segment_type FROM dba_segments WHERE TABLESPACE_NAME = '[ts]&#8217;;<br \/><span style=\"font-weight: bold;\">move table to another ts:<\/span><br \/>ALTER TABLE  [table] MOVE TABLESPACE [ts];<br \/><span style=\"font-weight: bold;\">rebuild index after above:<\/span><br \/>ALTER INDEX  [index] REBUILD;<br \/><span style=\"font-weight: bold;\">check damage indexes:<\/span><br \/>SELECT index_name FROM user_indexes WHERE status=&#8217;UNUSABLE&#8217;;<br \/>ALTER INDEX  [index] REBUILD TABLESPACE [ts];<br \/><span style=\"font-weight: bold;\">rebuild damage indexes:<\/span><br \/>BEGIN<br \/>FOR rec in (SELECT index_name FROM dba_indexes WHERE status=&#8217;UNUSABLE&#8217; and owner='[user]&#8217;)<br \/>LOOP<br \/>DBMS_UTILITY.EXEC_DDL_STATEMENT(&#8217; ALTER INDEX [user].&#8217;||rec.index_name||&#8217; REBUILD&#8217;);<br \/>END LOOP;<br \/>END;<br \/><span style=\"font-weight: bold;\">move LOB segment to another ts:<\/span><br \/>ALTER TABLE [table]<br \/>MOVE LOB([lob_column]) STORE AS (<br \/>TABLESPACE [ts]<br \/>)<br \/><span style=\"font-weight: bold;\">move table with LOB segment to another ts:<\/span><br \/>ALTER TABLE [table]<br \/>MOVE TABLESPACE  LOB ([lob_column]) STORE AS (<br \/>TABLESPACE [ts]<br \/>)<br \/><size><span style=\"font-weight: bold;\">change ts for user:<\/span><br \/>ALTER USER  [user] DEFAULT TABLESPACE  [ts] TEMPORARY TABLESPACE [ts];<\/size><\/span><\/p>\n<div><span style=\"font-family: arial;\"><size><span class=\"Apple-style-span\" style=\"font-weight: bold;\">convert ts between OS:<\/span><\/size><\/span><\/div>\n<div><span class=\"Apple-style-span\" style=\"font-family: arial;\">CONVERT TABLESPACE '[ts_name]&#8217; TO PLATROFM = 'Linux IA (32-bit)&#8217; DB_FILE_NAME_CONVERT='[file_path]&#8217;;<\/span><\/div>\n<div><span style=\"font-family: arial;\"><size><br \/><\/size><\/span><\/div>\n<p><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>check space:SELECT tablespace_name,sum(bytes)\/1024\/1024 MB FROM dba_data_files GROUP BY tablespace_name ORDER by 1;SELECT tablespace_name,sum(bytes)\/1024\/1024 MB,sum(maxbytes)\/1024\/1024 maxbytes_MB FROM dba_data_files GROUP BY tablespace_name,maxbytes ORDER by 1;SELECT tablespace_name,file_name,bytes\/1024\/1024 use_MB,maxbytes\/1024\/1024 max_MB,(maxbytes-bytes)\/1024\/1024 left_MB FROM dba_data_files WHERE maxbytes 0&nbsp; ORDER by 1;SELECTtablespace_name,sum(bytes)\/1024\/1024 MB FROM dba_free_space GROUP BY tablespace_name;switch mode:ALTER TABLESPACE [ts] ONLINE|OFFLINE;prepare files to copy:ALTER TABLESPACE [ts] BEGIN|END BACKUP;change file name: ALTER [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[1],"tags":[79],"class_list":["post-160","post","type-post","status-publish","format-standard","hentry","category-bez-kategorii","tag-oracle-tablespaces"],"_links":{"self":[{"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/posts\/160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/comments?post=160"}],"version-history":[{"count":2,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":219,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/posts\/160\/revisions\/219"}],"wp:attachment":[{"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/media?parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/categories?post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/tags?post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}