In this post, I am sharing a demonstration on how to set the default value for a Datatime column in MySQL.
I know this very basic topic and nothing special about this, but I am writing here because this is one of the most asking questions by the MySQL Beginner.
Following is a small demonstration on this:
First, Create a table with default:
1
2
3
4
5
|
CREATE TABLE TestDefault
(
Name VARCHAR(50)
,MyDate DATETIME DEFAULT CURRENT_TIMESTAMP
);
|
Second, Insert a test record:
1
|
INSERT INTO TestDefault(Name) VALUES ('Anvesh')
|
Check the result:
1
2
3
4
5
|
SELECT * FROM TestDefault
Name | MyDate
----------------------------
Anvesh | 2015-10-25 17:47:50
|
0 comments:
Post a Comment