PHP MySql Web Hosting

PHP and MySQL Web Development

INSERT INTO limbs (thing,legs,arms) VALUES(’tripod’,3,0); INSERT INTO limbs

Filed under: MySQL Solutions — webmaster @ 4:44 am

INSERT INTO limbs (thing,legs,arms) VALUES(’tripod’,3,0); INSERT INTO limbs (thing,legs,arms) VALUES(’Peg Leg Pete’,1,2); INSERT INTO limbs (thing,legs,arms) VALUES(’space alien’,NULL,NULL); To execute the statements in this SQL script file in batch mode, change directory into the tables directory of the recipes distribution where the table-creation scripts are located, then run this command: % mysql cookbook < limbs.sql You'll note that the script contains a statement to drop the table if it exists before creating it anew and loading it with data. That allows you to experiment with the table without worrying about changing its contents, because you can restore the table to its baseline state any time by running the script again. The command just shown illustrates how to specify an input file for mysql on the command line. As of MySQL 3.23.9, you can read a file of SQL statements from within a mysql session by using a SOURCE filename command (or . filename, which is synonymous). Suppose the SQL script file test.sql contains the following statements: SELECT NOW( ); SELECT COUNT(*) FROM limbs; You can execute that file from within mysql as follows: mysql> SOURCE test.sql; +———————+ | NOW( ) | +———————+ | 2001-07-04 10:35:08 | +———————+ 1 row in set (0.00 sec) +———-+ | COUNT(*) | +———-+ | 12 | +———-+ 1 row in set (0.01 sec) SQL scripts can themselves include SOURCE or . commands to include other scripts. The danger of this is that it’s possible to create a source loop. Normally you should take care to avoid such loops, but if you’re feeling mischievous and want to create one deliberately to find out how deep mysql can nest input files, here’s how to do it. First, issue the following two statements manually to create a counter table to keep track of the source file depth and initialize the nesting level to zero: mysql> CREATE TABLE counter (depth INT); mysql> INSERT INTO counter SET depth = 0;

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP MySQL Web Hosting services

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by PHP MySQL Web Hosting