Data Definition Language

Oracle Data Structures


  • New tables can be created or when users work with the database
  • Memory is allocated for tables as needed. Memory for the database as a whole is assigned in advance, but it is possible to expand its size with the appropriate options
  • The data structure can be modified during operation of the system (unless I want them to undergo changes by users)
  • Users can set up its own private structures


Creating tables

The table name must conform to the rules of naming Oracle database objects:


  • Object name must start with a letter
  • The name can contain letters, digits and the underscore. Possible, but not recommended to use $ and # characters
  • upper and lower case are equivalent
  • name length must not exceed 30 characters
  • within the database can not have two objects with the same name - the name must be unique
  • The name can not be reserved for the name of the language
  • if the name does not meet these recommendations, it must be surrounded by double quotes. Then are case sensitive
  • Defining the table we give a list of columns described by the column name, its type, and sometimes the length of the stored value.


Types of columns

Each column must have a specific data type:

  • CHAR (n) - string of characters of any fixed length parameter n indicates the maximum string length
  • VARCHAR2 (n) and VARCHAR (n) - variable-length string, the parameter n indicates the maximum string length
  • NUMBER (p, s) - number with precision p and scale s, the precision (number of significant digits) can range from 1 to 38 scale (number of digits after the decimal) values ​​from -84 to 127
  • DATE - dates ranging between January 1, 4712 years and 31 December 4712 AD, the date is also stored time component
  • LONG - variable-length character string with a maximum of 2 GB, the table can be only one column of type LONG
  • RAW (n) - byte string of length n bytes, the maximum n = 2000
  • LONG RAW - byte string of up to 2 GB, the table can be only one column of type LONG RAW
  • ROWID - to store the physical addresses of rows

The command to create tables

To build the tables, use the CREATE TABLE statement:

CREATE TABLE arrayname
(Col_name type (size),
column_name type (size),
, ...);

Example

Create a table DEPT:
CREATE TABLE DEPT
(DEPTNO NUMBER (2),
DNAM VARCHAR2 (12),
LOC VARCHAR2 (12));

Terms of integrity

When defining a table, we can determine what conditions should meet the data in rows entering the array. Such conditions are called conditions of integrity (constraints).

We require the fulfillment of the values ​​in that column was required to come from the specified range to be unique, etc.

No comments: