Oracle SQL in 10 Minutes - Asim Abbasi

CH1: SQL Basics | CH2:  SQL Operators | CH3:  SQL Built-in Functions | CH4: SQL Joins | CH5: UPDATE, INSERT & DELETE Statements | CH6: CREATE, ALTER & DROP Statements | CH7: Constraints | CH8: Linking Tables vs Joining Tables | CH9: SQL Statements for Other Database Objects | CH10: SQL Statements for Database Security

Chapter 6: CREATE, ALTER & DROP Statement

Page #: 1 | 2 | 3 | 4

 

CREATE & DROP Table Statements:

Figure 12: CREATE/DROP TABLE Statement
________________________________________


Before explaining how to create table I would like to give you slight explanation about the word “Schema”, what it is? And what it means in Oracle Jargon. Schema is basically a Latin word and it means, a diagrammatic representation; an outline or model. Schema can be visualized by looking at the organization chart of a company e.g., the one shown below.

Figure 13: Organizational Chart. Showing Chief’s Schema
________________________________________

Each user we create in Oracle database is a “Schema”. All the objects (tables, Views, Sequences etc.) created by that user fall under his schema. Oracle DBA (Database Administrator) is the owner of all the schemas and the objects under each. He is just like the “Chief” in the Figure 13.

To create table first you have to decide which schema you want this table to be in. Then log into Oracle system (usually SQL*Plus) using that schema’s (or User’s) credentials i.e. username/password. Upon successful login, execute the CREATE TABLE command to create required table under that schema.

If you look in the Figure 12, especially on the syntax of CREATE TABLE statement, there is something mentioned called the “data type” besides table name which will be name of the table that you want to create and the columns names which will be the names of the columns that you want to be in the table. While creating table you also have to tell Oracle what type of data goes in which column or in other words data type of each column e.g., if you tell oracle that I want to store date type of information in first column and text type of information in second column then while inserting data into this table using the INSERT statement you cannot insert number or currency information in first column. If you do so, you will get “type miss-match” like error. Now lets see what different types of “Data Types” are available in Oracle so we can utilize them in the data type assignment of each column within a table in the CREATE TABLE statement.

 

Chapter 5: CREATE, ALTER & DROP Statement

Page #: 1 | 2 | 3 | 4

CH1: SQL Basics | CH2:  SQL Operators | CH3:  SQL Built-in Functions | CH4: SQL Joins | CH5: UPDATE, INSERT & DELETE Statements | CH6: CREATE, ALTER & DROP Statements | CH7: Constraints | CH8: Linking Tables vs Joining Tables | CH9: SQL Statements for Other Database Objects | CH10: SQL Statements for Database Security

Share with others: