How to increase allocated table size for particular table using db2 command - db2

How to increase allocated table size for particular table using DB2 command.Or is there a alternative way to increase memory for all table by 5mb at once.

you do not increase the memory for the table, but for the tablespace it is located in.
select tbspace from syscat.tables where tabname = 'MYTAB'
db2 "alter tablespace tbspace extend (all 100000)

Related

Estimating effect size of dropping columns in PostgreSQL

I have a table in PostgreSQL with two columns containing images as text (not my decision ..). So, now I do not need these columns and I'm planning to delete them. But I'd faced a problem when I wanted to estimate the "effect" of dropping the columns, i.e. how much size of the table will change.
The problem is that PostgreSQL shows the same size for old and new tables. Which is very weird because I'm dropping two "heavy" columns.
Here is the code of comparison:
-- Create two copies of the table
CREATE TABLE oldwords (LIKE "words" INCLUDING INDEXES);
INSERT INTO oldwords SELECT * FROM "words";
CREATE TABLE newwords (LIKE "words" INCLUDING INDEXES);
INSERT INTO newwords SELECT * FROM "words";
-- Drop columns containing images
ALTER TABLE "newwords"
DROP COLUMN image_black,
DROP COLUMN image_colored;
-- Update stats of the tables
VACUUM ANALYZE "oldwords";
VACUUM ANALYZE "newwords";
-- Compare size
SELECT
relname as "Table",
pg_size_pretty(pg_total_relation_size(relid)) As "Size",
pg_size_pretty(pg_total_relation_size(relid) -
pg_relation_size(relid)) as "External Size"
FROM pg_catalog.pg_statio_user_tables
WHERE relname LIKE '___words'
ORDER BY pg_total_relation_size(relid) DESC
-- RESULT
Table Size External Size
newwords 296 MB 205 MB
oldwords 296 MB 205 MB
Am I doing something wrong? Why are the sizes same? And what is the correct way to do it?
From ALTER TABLE:
The DROP COLUMN form does not physically remove the column, but simply
makes it invisible to SQL operations. Subsequent insert and update
operations in the table will store a null value for the column.
Thus,
dropping a column is quick but it will not immediately reduce the
on-disk size of your table, as the space occupied by the dropped
column is not reclaimed. The space will be reclaimed over time as
existing rows are updated. (These statements do not apply when
dropping the system oid column; that is done with an immediate
rewrite.)
To force immediate reclamation of space occupied by a dropped column, you can execute one of the forms of ALTER TABLE that performs a rewrite of the whole table. This results in reconstructing each row with the dropped column replaced by a null value.

sufficient page size does not exist - DB2 insert

I am having a DB2 query(simple insert statement) which is trying to insert some 27 columns. Out of those columns 1 is Clob and the issue is there. For my Clob column, sometimes the value might even contain 28K characters. And in such extreme cases, I am getting the below error,
A system temporary table space with sufficient page size does not exist .. SQLCODE=-1585, SQLSTATE=54048, DRIVER=3.64.82
As I googled and gone through some pages, there is an entity called System Temporary Table Space which will be used by the DB when executing the query.(I am not sure, but few pages says that it will be used only for sorting and joining, but i don't have either in my query).
After going through few suggestions I created a System Temporary Table Space with the page size of 32K, using the below query,
CREATE SYSTEM TEMPORARY TABLESPACE STB PAGESIZE 32K MANAGED BY SYSTEM USING ( 'C:\DB2\NODE0005') BUFFERPOOL BP32K
Still my issue continues. What would be the proper way to have my query executed. I am trying to understand the importance of System Temporary Table Space, Page Size,etc.. But any help that could fix this issue for now would be greatly appreciated.
AngocA's soultion seems to work in principle it goes along the lines of
http://www-01.ibm.com/support/docview.wss?uid=swg21529563.
For the 4K system temporary table space the command
CREATE SYSTEM TEMPORARY TABLESPACE STB_4 PAGESIZE 4K
will work immediately if 4K is your default page size. To avoid an SQL 1582N error http://www.ibm.com/support/knowledgecenter/SSEPGG_9.5.0/com.ibm.db2.luw.messages.sql.doc/doc/msql01582n.html
you might need to create 8K,16 and 32 K bufferpools:
CREATE BUFFERPOOL BP8K pagesize 8K
CREATE SYSTEM TEMPORARY TABLESPACE STB_8 PAGESIZE 8K BUFFERPOOL BP8K
CREATE BUFFERPOOL BP16K pagesize 16K
CREATE SYSTEM TEMPORARY TABLESPACE STB_16 PAGESIZE 16K BUFFERPOOL BP16K
CREATE BUFFERPOOL BP32K pagesize 32K
CREATE SYSTEM TEMPORARY TABLESPACE STB_32 PAGESIZE 32K BUFFERPOOL BP32K
You can create a system temporary tablespace for each page as SMS (System Managed). In that case, your query will always find a tablespace with the appropriate page size.
CREATE SYSTEM TEMPORARY TABLESPACE STB_4 PAGESIZE 4K
CREATE SYSTEM TEMPORARY TABLESPACE STB_8 PAGESIZE 8K
CREATE SYSTEM TEMPORARY TABLESPACE STB_16 PAGESIZE 16K
CREATE SYSTEM TEMPORARY TABLESPACE STB_32 PAGESIZE 32K
When creating SMS, the tablespace will not preallocate space in the disk, and they only growth as they are used.
First you need to check the existing pagesize. You can create bufferpool of pagesize 8k,16k,32k etc.
First create bufferpool with required pagesize and then create system temporary tablespace with the required pagesize. Below are the step-by-step procedure.
sql1585n-system-temporary-tablespace-issue

How a Table space for a query execution is chosen? - DB2

For one of my issue, I am trying to understand the functionalities of below DB2 entities,
System Temporary table space.
Page Size.
Table Space.
Buffer Pool.
And below is my observation,
There is a TableSpace linked to a table in the DB2 table syscat.tables
The TableSpaces are linked to BufferPool with the relation defined in syscat.tablespaces
System Temporary table space is the table space that the DB might use while executing the query.
Page Size is an unit that defines the limit of a TableSpace and says how much data can a TableSpace can hold.
Is there something wrong in my above understandings? And when I excute a query how does the DB chooses which TableSpace to choose?

DB2 create table and insert in tablespace

my DBA created three different tablespaces in DB2 in order to store the same table (TABLE_IN_TBS), switching on a date field.
CREATE LARGE TABLESPACE "TBS_x" IN DATABASE PARTITION GROUP NODO0 PAGESIZE 32768 MANAGED BY DATABASE
USING (FILE 'x.LRG' 1G) ON DBPARTITIONNUMS (0)
EXTENTSIZE 32
PREFETCHSIZE AUTOMATIC
BUFFERPOOL BP32K0
OVERHEAD 12.670000
TRANSFERRATE 0.180000
AUTORESIZE YES
MAXSIZE 30 G
NO FILE SYSTEM CACHING
DROPPED TABLE RECOVERY ON;
Then I have TBS_x in which data in predefined range will be add, TBS_x+1 for the next range and so on..
My question is: I have to create the same table TABLE_IN_TBS in the different tablespaces? With the following syntax?
CREATE TABLE TABLE_IN_TBS
(
SomeColumns....
) TABLESPACE TBS_x;
And in which way I can refer to different tablespaces in order to insert data in the right tablespace based on my date field to switch?
I think you're talking about a partitioned table. It is defined like this:
CREATE TABLE TABLE_IN_TBS
(
SomeColumns....
)
PARTITION BY (your_date_column)
(STARTING FROM '2013-09-30' ENDING AT '2013-09-30' IN TABLESPACE TBS_1),
(STARTING FROM '2013-10-01' ENDING AT '2013-10-01' IN TABLESPACE TBS_2),
...;

how to increase the size of a table in oracle?

i have a table "DEPT" ,
let me know how to increase the size of a table.
Are you talking about increasing the size of the TableSpace?
Here is the command for that
alter database datafile '<full_file_name>' resize <size>M;
example
ALTER DATABASE
DATAFILE '/u01/oradata/userdata01.dbf'
RESIZE 500M;
Alter Tablespace sysaux
ADD DATAFILE '/u01/app/oracle/prod1/oradata/sysaux02.dbf' SIZE 500M;