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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.