-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDATE DATETIME and TIMSTAMP Data type in SQL.txt
More file actions
36 lines (31 loc) · 1.23 KB
/
DATE DATETIME and TIMSTAMP Data type in SQL.txt
File metadata and controls
36 lines (31 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//DATE DATETIME and TIMSTAMP Data type in SQL
1. DATE -> It display data values in YYYY-MM-DD format.
syntax: column_name DATE;
e: age DATE;
2. DATETIME -> It display DATETIME value in YYYY_MM_DD HH:mm:ss format.
syntax: column_name DATETIME;
ex: data_of_join DATETIME
3. TIMESTAMP -> It also display data and time.
syntax: column_naem TIMESTAMP;
ex: login_dt TIMESTAMP;
Example of DataType;
stu_id - int;
name - VARCHAR;
Address - TEXT;
dob -> DATE;
fees -> DEC;
Output example:
mysql> create table student_reg(s_id int (10) ,name varchar(50), address tex
t,dob date, fees dec (10,2));
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> desc student_reg;
+---------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------------+------+-----+---------+-------+
| s_id | int | YES | | NULL | |
| name | varchar(50) | YES | | NULL | |
| address | text | YES | | NULL | |
| dob | date | YES | | NULL | |
| fees | decimal(10,2) | YES | | NULL | |
+---------+---------------+------+-----+---------+-------+
5 rows in set (0.00 sec)