Jump to content
  • 0

Adding automatically Database Table


Poring King

Question


  • Group:  Members
  • Topic Count:  61
  • Topics Per Day:  0.02
  • Content Count:  911
  • Reputation:   166
  • Joined:  11/27/14
  • Last Seen:  

Hello i always encounter this kind of stupid problem when im creating a sql table automatically .

This is my automatic sql

/*
DROP TABLE IF EXISTS `WOE`;
CREATE TABLE `WOE` (
  `test` int(11) unsigned NOT NULL auto_increment,
  `test1` varchar(34) NOT NULL default '',
  `test2` INT(11) NOT NULL,
  `test3` DATETIME NULL,
  `test4` DATETIME NULL,
  `test5` TINYINT(1) NOT NULL,
  `test6` DATETIME NULL,
  PRIMARY KEY (`test`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8;
*/

I tried to use this on my phpmyadmin and its work fine but when i try to put this on npc it would not create .. Any IDEA ? I learn from my mistake so please point it out my mistake ^_^ Thx

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

well yes its actually better to create table with phpmyadmin
why use OnInit and access query_sql everytime ? query_sql is a slow operation (a simple line is fine but if having multiple lines you'll start notice the lag)

anyway, I don't recommend using OnInit, but here's the answer

-	script	jsdfksfj	1_F_MARIA,{
OnInit:
	.@query$ = "CREATE TABLE IF NOT EXISTS `blah` ("
	         +   "`id` INT AUTO_INCREMENT PRIMARY KEY,"
	         +   "`points` INT,"
	         +   "`breaktimestamp` DATETIME,"
	         +   "KEY(`points`)"
	         + ") ENGINE = InnoDB;";
	query_sql .@query$;
}

by the way I didn't see your table is index properly
anything that has SELECT <something> FROM `table` WHERE `column` ... this `column` has to be index

Link to comment
Share on other sites

Join the conversation

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

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

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