Rabu, 03 Februari 2010

SQL to insert Timestamp Data Type into MySQL

A timestamp is a sequence of characters, denoting the date and/or time at which a certain event occurred.

The time at which an event is recorded by a timestamp (e.g., entered into a log file) should be very, very close to the time of the occurrence of the event recorded.

example of a timestamp in mysql : 2010-02-02 18:15:37

How Using SQL to insert Timestamp Data Type into MySQL ?

(Provided Table First)

CREATE TABLE `guest_book` (                                                      
              `id_gb` int(4) NOT NULL AUTO_INCREMENT,                                        
              `pengirim` varchar(20) NOT NULL DEFAULT '',                                    
              `email` varchar(50) NOT NULL DEFAULT '',                                       
              `isi` text NOT NULL,                                                           
              `tgl` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
              PRIMARY KEY (`id_gb`)                                                          
            )

Just Running A Query


insert into guest_book
(pengirim,
email,
isi,
tgl
)
values
('pengirim',
'picas @ unud.com',
'isi',
CURRENT_TIMESTAMP
)

in the  provided table.


And The Result :
Timestamp, MySQL Timestamp, datetime query, log SQL, Catatan waktu SQL, Field Waktu MySQL, Waktu MySQL
Related Post:

Tidak ada komentar: