Jump to content


Photo

Insert .sql


  • Please log in to reply
3 replies to this topic

#1 homie_g

homie_g
  • Members
  • Pip
  • Newbie
  • 2 posts
  • LocationMelbourne, Aus

Posted 20 August 2003 - 03:25 AM

how do i use a .sql file to create database(s) and tables?

#2 DylanBlitz

DylanBlitz
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts
  • LocationOC Baby!

Posted 20 August 2003 - 04:10 AM

a .sql file is basically a flat text file that will create your tables and insert data when you put yoru fields in. Mostly what I\'ve used them for is backup. I load phpmyadmin, click export, and then export a .sql file which will create everything again if it goes down. Here is a sample of some stuff.

You create the db on your own, then here is a table:


DROP TABLE IF EXISTS `button`;CREATE TABLE `button` (  `butt_id` int(11) NOT NULL auto_increment,  `butt_name` varchar(150) NOT NULL default \'\',  `butt_action` varchar(150) default NULL,  `butt_link` varchar(150) NOT NULL default \'\',  PRIMARY KEY  (`butt_id`)) TYPE=MyISAM AUTO_INCREMENT=64;
That tells the mysql that if the db already has a \"button\" table to get rid of it and create one with these fields. Then you insert data into it:

INSERT INTO `button` VALUES (10, \'News - Add\', \'add\', \'admin_news.php\');INSERT INTO `button` VALUES (11, \'News - Modify\', \'modify\', \'admin_news.php\');INSERT INTO `button` VALUES (12, \'News - Delete\', \'delete\', \'admin_news.php\');

Hope that helps you. If it\'s not what you meant then let me know :)

#3 homie_g

homie_g
  • Members
  • Pip
  • Newbie
  • 2 posts
  • LocationMelbourne, Aus

Posted 20 August 2003 - 05:24 AM

thanx.


im using mysql on my harddrive for testing etc. and im i n00b :oops:

i no how to import from a .txt file but how to do export to a .txt file?

#4 DylanBlitz

DylanBlitz
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts
  • LocationOC Baby!

Posted 20 August 2003 - 05:25 AM

are you using phpmyadmin? if you are then it defaults to db.sql




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users