0

Hi,
I tried to use dynamic table names like:

create table outgoing_%Y%m%d (                                                                                                                                            
   ip_src CHAR(15) NOT NULL,                                                                                                                                                             
   ip_dst CHAR(15) NOT NULL,                                                                                                                                                             
   src_port INT(2) UNSIGNED NOT NULL,                                                                                                                                                    
   dst_port INT(2) UNSIGNED NOT NULL,                                                                                                                                                    
   stamp DATETIME,                                                                                                                                                               
   PRIMARY KEY (ip_src, ip_dst, src_port, dst_port, stamp_inserted)                                           
);

but every time i got message about syntax error:

error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%Y%m%d (' at line 1

So, I'm even not sure, it is possible to use %Y%m%d in name or not?
Cheers,
flybro

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by drjohn
0

The %Y%m%d are formatting instructions used INSIDE the date_format() function. Outside that function they are probably totally meaningless. They are probably being interpreted literally and may not be valid characters to include in a table name, unless the entire name was quoted, which would then cause you problems of having to use quotes in evvery query of that table name.

So if you are expecting the table name to turn into outgoing_20010-03-28 you will have to find another way to get this name.

Edited by drjohn: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.