Creating a table in Oracle focuses on the table field type and corresponding constraints. 1. create table statement Createtabletname (Fied1 Type 1, Fied1 type 2,
Creating a table in Oracle focuses on the table field type and corresponding constraints. 1. Create table statement Create table tname (Fied1 Type 1, Fied1 type 2,
Creating a table in Oracle focuses on the table field type and corresponding constraints.
1. Create a table statement
Create table tname
(
Fied1 Type 1,
Fied1 type 2,
........
);
Create table tname as subquery -- copy existing tables
2. Field Type
Varchar (n) ---- create a field that can store n characters. The data length can be automatically extended. It is compatible with other databases and only occupies two bytes of Chinese characters and full-angle characters, numbers, each English character is a byte;
Varchar2 (n) ---- create a field that can store n characters. The data length can also be increased automatically. It is compatible with other databases. All characters are processed in two bytes (generally ).
Number (n, d) --- create a number. n is an integer, and d is the precision bit.
Date --- create Date Format Field
CLog --- stores large volumes of text
Constraints
Primary key --- Primary key constraint, uniqueness and non-null
Unique ----- uniqueness
Not Null ----- non-Null
Check ------ check and processing sex Check ('M', 'w') restrict the inserted sex field to only two types
Foreign key refrence table (fied) ----- Foreign key, associated with the fied field of the table
Statements for manually creating constraints (except foreign keys) are
Constraint nameconditon (Fild )-----
Statements for manually creating foreign keys
Constraint foreign_name foreign key (fied1) refrence t (f2 );
Modify Table Structure
Alter table tname [Add | Drop | modify] ----- You can Add, delete, or modify table fields.
Related reading:
ORA-02291: violating full constraints (*)-parent keywords not found
Obtain the table storage location and create a tablespace in Oracle
Precautions for creating and inserting tables in Oracle
Oracle creates tablespaces, creates users, authorizes, revokes permissions, deletes users, and deletes tablespaces.
Create Table, prompting ORA-00959: tablespace 'mc _ data' does not exist