sql - Setting a column as timestamp in MySql workbench? -


this might elementary question, i've never created table timestamp() before, , i'm confused on put parameters. example, here:

enter image description here

i randomly put timestamp(20), 20 parameter signify here? should put in here?

i googled question, didn't come so... anyway i'm new sql, appreciated, thank you!!

you don't need put length modifier on timestamp. timestamp itself.

but aware first timestamp column defined in table subject automatic initialization , update. example:

create table foo (id int, ts timestamp, val varchar(2));  show create table foo;   create table `foo` ( `id` int(11) default null, `ts` timestamp not null default current_timestamp on update current_timestamp, `val` varchar(2) default null )  

what goes in parens following datatype depends on datatype is, datatypes, it's length modifier.

for datatypes, length modifier affects maximum length of values can stored. example, varchar(20) allows 20 characters stored. , decimal(10,6) allows numeric values 4 digits before decimal point , 6 after, , effective range of -9999.999999 9999.999999.

for other types, length modifier doesn't affect range of values can stored. example, int(4) , int(10) both integer, , both can store full range of values allowed integer datatype.

what length modifier in case informational. specifies recommended display width. client can make use of determine how space reserve on row displaying values column. client doesn't have that, information available.

a length modifier no longer accepted timestamp datatype. (if running old version of mysql , it's accepted, ignored.)


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -