![]() ![]() INSERT INTO STUDENT (stud_id, stud_address, stud_name) VALUES (2, 'Mumbai', 'PQR') It will take the automatic value as the current timestamp at the time of insertion as follows.Ĭode: INSERT INTO STUDENT (stud_id, stud_address, stud_name) VALUES (1, 'Pune', 'ABC') In the below example, we have created the default current timestamp on the admission_date column.Ĭode: CREATE TABLE student (stud_id serial PRIMARY KEY, stud_address varchar(255) NOT NULL, stud_name varchar(255) NOT NULL, admission_date TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP) Īfter creating the student table, we do not need to insert a value in the column name as admission_date. In the below example, we have used the current timestamp as the default value in the student table. Use the current timestamp in the column as the default value: We did not use () because we have not defined the precision value in the example below. In the below example, we have not used precision value with the current timestamp. We have used five fractional seconds to define the current timestamp.Ĭurrent timestamp without using precision value: In the below example, we have used a precision value of 5 with the current timestamp. The below example shows that we do not need to use () when we have not used the precision parameter: If we have used () without a precision parameter, it will show a syntax error.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |