How to create a new table in DB2?
To create a new table in DB2, you can follow these steps:
- Open the DB2 console or use a command line tool to connect to the DB2 database.
- Create a new table with the specified name and field information using the following SQL statement:
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
...
);
In this statement, table_name is the name of the new table, column1 and column2 are the names of the fields in the table, and datatype is the data type of the fields.
- Constraints such as primary keys can be added when creating a table, for example:
CREATE TABLE table_name (
column1 datatype PRIMARY KEY,
column2 datatype NOT NULL,
...
);
- By executing the SQL statement above, you can create a new table in the DB2 database.
It is important to ensure that there are sufficient permissions in the database to create new tables before doing so.