Jump to content

[SOLVED] datetime help


sasori

Recommended Posts

im practicing to build a database, i was building a customerorderinfo database with 3 tables

- customer table

- item table

- item_order table

 

but am having problem creating a datetime in the item_order table

here's my supposed to be syntax in item_order table

 

CREATE TABLE item_order (
cust_id BIGINT,
item_order SERIAL,
date  <---  this is the part i don't know what to place LOL

 

???

Link to comment
https://forums.phpfreaks.com/topic/120989-solved-datetime-help/
Share on other sites

This will enter the current date/time when the record is inserted:

  date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP

 

Two other points though, unless you're going to have over 2 billion customers, BIGINT is unessisary and is bad practice as far as mysql performance goes. "SERIAL" is just an ALIAS for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE, so again.. look into INT or TINYINT

Link to comment
https://forums.phpfreaks.com/topic/120989-solved-datetime-help/#findComment-623714
Share on other sites

This will enter the current date/time when the record is inserted:

  date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP

 

Two other points though, unless you're going to have over 2 billion customers, BIGINT is unessisary and is bad practice as far as mysql performance goes. "SERIAL" is just an ALIAS for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE, so again.. look into INT or TINYINT

 

thanks for the tips sir.. but what about the YYYY-MM-DD and HH:MM:SS thing goes ?

Link to comment
https://forums.phpfreaks.com/topic/120989-solved-datetime-help/#findComment-623722
Share on other sites

by default MYSQL will use the format the current date/time to YYYY-MM-DD HH:MM:SS in the column when you do the insert, you can remove the "DEFAULT CURRENT_TIMESTAMP" and look up how to change the format around here if nessisary:

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

Link to comment
https://forums.phpfreaks.com/topic/120989-solved-datetime-help/#findComment-623726
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.