How to insert a timestamp in Oracle?

Blog-39.jpg

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 syntax below:

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 name

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

Technical Writer | Business Analyst

Yash Vardhan Gupta is an expert in data and business analysis, skilled at turning complex data into clear and actionable insights. He works with tools like Power BI, Tableau, SQL, and Markdown to develop effective documentation, including SRS and BRD. He helps teams interpret data, make informed decisions, and drive better business outcomes. He is also passionate about sharing his expertise in a simple and understandable way to help others learn and apply it effectively.

Intellipaat