Notice
Recent Posts
Recent Comments
Link
«   2025/01   »
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
Tags
more
Archives
Today
Total
관리 메뉴

방카@Dev

[MySQL] Insert 시 자동갱신 TIMESTAMP 본문

BackEnd/DB

[MySQL] Insert 시 자동갱신 TIMESTAMP

방카킴 2024. 5. 14. 16:20
칼럼이름 / timestamp / default current_timestamp
CREATE TABLE HIST_PAY(		
pay_num int auto_increment primary key,		
user_id varchar(20) not null,		
item_name varchar(20) not null,		
item_num int not null,		
pay_date timestamp default current_timestamp,		
foreign key(user_id) references user(user_id) );

 

 

➡️ 예시 DB(hist_pay)

col_num col_type detail
pay_num INT auto_increment, primary_key
user_id Varchar(20) foreign key
item_name Varchar(20)  
item_num INT  
pay_date Timestamp current_timestamp