![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
How to create a DB2 table TAB1 with 4 columns, Student ID, Enrollment ID, Name and Age?
A table is a logical structure of a data in a DB2. A table consists of a column which represents the attribute and rows represents the entity. Below command can be issued in order to create a new DB2 table.
CREATE TABLE DBSET1.TAB1 (STUDENT_ID CHAR(10) NOT NULL, ENROLLMENT_ID CHAR(20) NOT NULL, NAME VARCHAR(50), AGE SMALLINT PRIMARY KEY (STUDENT_ID));
The CREATE TABLE reserved words are followed by the name of the table which we have to create in the format <DATABASENAME.TABLENAME>. Here DBSET1 is the database and TAB1 is the table.
The name of the column has to be mentioned followed by data type for each of the columns like CHAR for character data, VARCHAR for variable character (used for indeterminate length) and SMALLINT for small integer value which occupies 2 bytes.
The PRIMARY KEY parameter defines the primary key of the table which has to be unique throughout the rows present in the table.