954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Tables naming convetion

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

Flybro
Newbie Poster
2 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
 

What do you mean by dynamic table names

mwasif
Posting Whiz
315 posts since Dec 2007
Reputation Points: 29
Solved Threads: 48
 

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.

drjohn
Posting Pro in Training
448 posts since Mar 2010
Reputation Points: 76
Solved Threads: 80
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: