- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6702 Articles for Database
![Mandalika](https://www.tutorialspoint.com/assets/profiles/223769/profile/60_143952-1595686763.jpg)
325 Views
A segmented table space is divided in multiple segments. A segment is defined as a contiguous set of fixed number of pages. This fixed number is defined during the table space definition using the SEGSIZE parameter. The SEGSIZE serves multiple purposes - It defines the tablespace as segmented and also defines the size of the segment.In a segmented tablespace, the rows of a table are stored in one or more segments and a particular segment can only have rows from one table.The segmented tablespace can be created by using the CREATE TABLESPACE command with SEQSIZE parameter as below.CREATE TABLESPACE TABSPA1 ... Read More
![Mandalika](https://www.tutorialspoint.com/assets/profiles/223769/profile/60_143952-1595686763.jpg)
94 Views
A tablespace is a collection of data files which resides inside a DB2 database. It is used to organize the data logically. Any DB2 database contains at least one tablespace and in the real world scenario there are multiple tablespaces within a database which are allocated for different business units. In order to create a new tablespace, we have to provide the command as below−CREATE TABLESPACE TABSPA1 IN DBSPAC1 USING STOGROUP STG1 PRIQTY 50 SECQTY 50 BUFFERPOOL BP02 ERASE NOThe CREATE AND TABLESPACE are the reserved words which are followed by the name of ... Read More
![Mandalika](https://www.tutorialspoint.com/assets/profiles/223769/profile/60_143952-1595686763.jpg)
351 Views
A compression is used to save the DB2 disk space. The compression can be used either at row level or at a page level. In order to add a row compression in a DB2 table, we can give the following command−ALTER TABLE DBSET1.TAB1 COMPRESS YES STATICWe have to use ALTER TABLE for the compression of the DB2 table. The ALTER TABLE reserved words are followed by the name of DB2 table qualified by database. COMPRESS YES STATIC will complete the row compression for the said table.
![Mandalika](https://www.tutorialspoint.com/assets/profiles/223769/profile/60_143952-1595686763.jpg)
642 Views
We can delete the unused tables in the DB2. However, we must keep in mind that if we delete a table then all the indexes associated with the table are also dropped. Moreover, the triggers and views for the deleted table will become inaccessible. To delete any table in DB2, we can issue below command.DROP TABLE DBSET1.TAB1The DROP TABLE reserved word will be followed by the name of the table qualified by the database. The mentioned table will be deleted from the DB2 permanently.
![Mandalika](https://www.tutorialspoint.com/assets/profiles/223769/profile/60_143952-1595686763.jpg)
116 Views
DB2 gives us an option of modifying the attribute of the existing column in a table. We have to use the ALTER COLUMN parameter with ALTER TABLE as below in order to achieve this.ALTER TABLE DBSET1.TAB1 ALTER COLUMN NAME SET DATATYPE CHAR(50);The ALTER TABLE reserved words are followed by the name of the table qualified by a database, which is DBSET1.TAB1 in this case. Similarly, ALTER COLUMN is followed by the name of the column which needs to be modified, which NAME (of the student) in this case.In the SET DATATYPE parameter, we can pass the ... Read More
![Mandalika](https://www.tutorialspoint.com/assets/profiles/223769/profile/60_143952-1595686763.jpg)
147 Views
DB2 gives us an option to copy the structure of an existing table to a new table. To copy the attributes and column of table TAB1 to a new table TAB2 we can use the following command−CREATE TABLE DBSET1.TAB2 LIKE DBSET1.TAB1The CREATE TABLE reserved words are followed by table name. The table name needs to be qualified by a database in which it will reside. In this case this new table is TAB2 and its database is DBSET1.The LIKE parameter is used after that followed by the name of the original table qualified by its database i.e. DBSET1.TAB1The important ... Read More
![Mandalika](https://www.tutorialspoint.com/assets/profiles/223769/profile/60_143952-1595686763.jpg)
257 Views
A view is an alternative way of representing the data stored in a table. A view can be used to increase the performance of the query since the view contains very limited rows as compared to its source table. We can use the below command to create a view on an existing table TAB1.CREATE VIEW AGEVIEW (NAME, AGE, ENROLLMENT_ID) AS SELECT NAME, AGE, ENROLLMENT_ID FROM TAB1 WHERE AGE > 10;We have to use CREATE VIEW reserved words in order to create a new view. This will be followed by the name of the view (AGEVIEW).The columns ... Read More
![Mandalika](https://www.tutorialspoint.com/assets/profiles/223769/profile/60_143952-1595686763.jpg)
463 Views
A foreign key is a column in a table that establishes a referential link with another table. A foreign key can be defined during creation of table (CREATE TABLE command) or it can be defined by modifying the table (ALTER TABLE command). However, before defining any key as foreign key, make sure that an index is built up on that column. We can use the below command to define an existing column CLASS in table TAB1 as a foriegn key which links to table TAB2.ALTER TABLE TAB1 ADD FOREIGN KEY (CLASS) REFERENCES CLASSDATA (CLASS_ID);The ALTER TABLE reserved words are followed ... Read More
![Mandalika](https://www.tutorialspoint.com/assets/profiles/223769/profile/60_143952-1595686763.jpg)
793 Views
We can add a new column in an existing table as per the business requirements. Similarly, we can also remove a column from the table. This could be done using the ALTER table command as below.ALTER TABLE TAB1 ADD COLUMN ADDRESS VARCHAR(100);The ALTER TABLE reserved words are followed by the name of the table which we want to amend. In this case it is TAB1.To add a new column we will use ADD COLUMN and to remove the column we will use the REMOVE COLUMN parameter. This is followed by the name of the column. If this is an addition ... Read More
![Mandalika](https://www.tutorialspoint.com/assets/profiles/223769/profile/60_143952-1595686763.jpg)
134 Views
Constraints are used to restrict the data inserted at a particular column. Constraints can be used in such a way that a value can only be inserted if it satisfies the condition given in constraints. We can give the below parameter during CREATE TABLE command to add a constraint.CREATE TABLE DBSET1.TAB1 (STUDENT_ID CHAR(10) NOT NULL, ENROLLMENT_ID CHAR(20) NOT NULL, NAME VARCHAR(50), AGE SMALLINT CONSTRAINT NUMBER CHECK (AGE >=3 AND AGE