Log in

View Full Version : "Source this"


revloc02c
10-27-2010, 01:54 AM
What does "source this" mean?

As in:
"Source schema.sql (in the editor's /sql directory) into your database."


or another example:
"Source this:
CREATE TABLE rule_sets (
ruleset_id TINYINT UNSIGNED NOT NULL auto_increment,
name VARCHAR(255) NOT NULL,
PRIMARY KEY(ruleset_id)
);
INSERT INTO rule_sets VALUES(0, "default");
UPDATE rule_sets SET ruleset_id=0;
CREATE TABLE rule_values (
ruleset_id TINYINT UNSIGNED NOT NULL,
rule_name VARCHAR(64) NOT NULL,
rule_value VARCHAR(10) NOT NULL,
INDEX(ruleset_id),
PRIMARY KEY(ruleset_id,rule_name)
);"

Mind you, I don't want an explanation of the code block above--what it does and why, I just want to know what "Source this" means you are supposed to do with it.

Secrets
10-27-2010, 02:15 AM
What does "source this" mean?

As in:
"Source schema.sql (in the editor's /sql directory) into your database."


or another example:
"Source this:
CREATE TABLE rule_sets (
ruleset_id TINYINT UNSIGNED NOT NULL auto_increment,
name VARCHAR(255) NOT NULL,
PRIMARY KEY(ruleset_id)
);
INSERT INTO rule_sets VALUES(0, "default");
UPDATE rule_sets SET ruleset_id=0;
CREATE TABLE rule_values (
ruleset_id TINYINT UNSIGNED NOT NULL,
rule_name VARCHAR(64) NOT NULL,
rule_value VARCHAR(10) NOT NULL,
INDEX(ruleset_id),
PRIMARY KEY(ruleset_id,rule_name)
);"

Mind you, I don't want an explanation of the code block above--what it does and why, I just want to know what "Source this" means you are supposed to do with it.

It means load the mysql .sql file into your database. For the example listed, open up a MySQL command prompt and type "source schema.sql;"

If you are in the same folder as the SQL file on the command prompt, it will begin entering that schematics into the database. In this example, it is a table. It can also enter rows of data into your database, I always check what's being added before I 'source' it.

Hope that elaborates on it some.

core
11-09-2010, 10:24 PM
dont forget once you open your mysql to USE DBNAMEHERE; or it wont update your database. For ex.

use peq;
source schema.sql;