How to insert a timestamp in Oracle?

How to insert a timestamp in Oracle?

In this blog, we will learn how to insert a timestamp in SQL. Oracle is a database software that uses the Relational database management concept, which means we can store the data in the form of tables.

Table of contents:

How to insert a timestamp in Oracle?

To insert a timestamp in Oracle, we have to follow the below syntax:

Syntax:

INSERT INTO table_name (timestamp_column) 
VALUES (CURRENT_TIMESTAMP);

Where,

  • CURRENT_TIMESTAMP  is the current date and time
  • table_name is the name of the table.
  • Timestamp_column  is the column names

Example to insert a timestamp in Oracle?

Let’s learn this concept with the below example, suppose we create a table named Employee, and we want to insert the hiring date of the employee.

Create a table

CREATE TABLE employee (
    employee_id INT,
    hire_date TIMESTAMP
);

Insert data into the table

INSERT INTO employee (employee_id, hire_date) 
VALUES (1, SYSTIMESTAMP);

INSERT INTO employee (employee_id, hire_date) 
VALUES (2, TIMESTAMP '2024-11-15 10:30:00');

Printing the table

SELECT * FROM employee;

Output:

employee_id hire_date
123-JAN-25 01.26.03.918690 PM
215-NOV-24 10.30.00.000000 AM

Conclusion

So far in this article, we have learned how we can insert a timestamp in Oracle with an example. If you want to excel in your career in SQL, you should visit our SQL course. If you want to excel in your career in SQL, you may refer to our SQL Course

About the Author

Data Engineer

As a skilled Data Engineer, Sahil excels in SQL, NoSQL databases, Business Intelligence, and database management. He has contributed immensely to projects at companies like Bajaj and Tata. With a strong expertise in data engineering, he has architected numerous solutions for data pipelines, analytics, and software integration, driving insights and innovation.

business intelligence professional