Home >Database >Oracle >How to create a table in oracle database

How to create a table in oracle database

下次还敢
下次还敢Original
2024-04-18 23:54:15422browse

The steps to create a table in Oracle database are as follows: Open a database session. Use the CREATE TABLE statement to define the table's name, column names, and data types. Execute the statement and submit it using the COMMIT command. Use the DESC command to verify the creation of the table.

How to create a table in oracle database

Steps to create a table in Oracle database

The process of creating a table in Oracle database is very simple, you can follow Proceed as follows:

  1. Open a database session: Use Oracle client or other tools to connect to the target database.
  2. Create table statement: Use the following syntax to create a table statement:
<code>CREATE TABLE table_name (
  column_name1 data_type,
  column_name2 data_type,
  ...
);</code>

Where:

  • table_name is the name of the table to be created.
  • column_name1, column_name2, etc. are the column names of the table.
  • data_type is the data type of each column (for example: NUMBER, VARCHAR2, DATE, etc.).

For example, to create a table named "STUDENTS" that contains the columns "ID" (NUMBER), "NAME" (VARCHAR2), and "AGE" (NUMBER), you can use the following statement:

<code>CREATE TABLE STUDENTS (
  ID NUMBER,
  NAME VARCHAR2(255),
  AGE NUMBER
);</code>
  1. Execute statement: Use the COMMIT command to submit the create table statement.
  2. Verify table creation: Use the DESC command to view the structure of the table to verify that the table was successfully created.

The above steps will create a table containing the specified columns and data types.

The above is the detailed content of How to create a table in oracle database. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn