Manage data types and tables in Oracle

Source: Internet
Author: User
Date type date includes year, month, day, hour, minute, and second timestamp. This is an extended (timestamp) of the date data type of Oracle9i. The time of the date type is more accurate.

Date type date includes year, month, day, hour, minute, and second timestamp. This is an extended (timestamp) of the date data type of Oracle9i. The time of the date type is more accurate.

Date type
Date includes year, month, day, hour, minute, and second
Timestamp this is an extended (timestamp) timestamp of the date data type of Oracle9i.

Image Type

Blob binary data can store pictures and sounds for 4 GB


Oracle table management

Create a student TABLE statement

Create table student (
Xh number (4 ),
Xm varchar2 (20 ),
Sex char (2 ),
Birthday date,
Sal number (7,2)
);
Statement used to create a Tclass table

Create table Tclass (
Class_id number (2 ),
CName varchar2 (20)
);


Modify Table
Add a field class_id to the Student table.
Alter table student add (class_id number (2 ));

Modify a field xm in the Student table
Alter table student modify (xm varchar2 (30 ))

Delete a field xm in the Student table
Alter table student drop column xm;

How to change the default date in oracle (because the default date in oracle is "day month year ")

Alter session set nls_date_format = 'yy-mm-dd'


Use the is keyword to query null values
Select * from student where birthday is null;

Use the like keyword
Select * from student where xh like '% 100 ';

Update the birthday value of xh = 1234 in the student table to null.
Update student set birthday = null where xh = 1234

Delete data
Delete from student;

Oracle supports transaction rollback
Set savepoint;
Run the delete from student statement to delete all data in the table.
Then return to the point a we set.

Statement: rollback to;


After the execution, the data in the data table will return to the status before the deletion.

The structure of the table to be deleted using truncate is still in progress. No logs are written and the deleted records cannot be retrieved, but the deletion speed is fast.
Execution statement: truncate table student

Delete a table
Delete deletes the table structure. This table does not exist.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.