Howto run a query from mysql command prompt
We need to follow the following steps to run database query from mysql comand prompt
1>Go to Mysql comand promt.
2>Specify the connecting password.
3>Now create a sql file which we can use as source file to run all the query.
That is our comand will be =>
source (The sql file location where everything specified)
4>The sql file should be look like..
rnd_db_ddl.sql
drop database if exists rnd_db;
create database rnd_db;
use rnd_db;
\. C:/Projects/rnd_db/organization.sql=>this comand will execute the organization.sql
from the mention path.
Organization.sql should be look like this
organization.sql
drop table if exists organization;
create table `organization` (
`organization_id` int not null auto_increment,
`organization_name` varchar(200) not null,
`is_active` tinyint(1) not null,
`address_line1` varchar(255) not null,
`address_line2` varchar(255) default null,
`city` varchar(100) not null,
`state` varchar(100) not null,
`country` varchar(100) not null,
`zipcode` varchar(15) default null,
`telephone_country_code` int default null,
`telephone_area_code` int default null,
`telephone` int default null,
`mobile_country_code` int default null,
`mobile` int default null,
`fax_country_code` int default null,
`fax_area_code` int default null,
`fax` int default null,
`url` varchar(255) default null,
`created_by` int not null,
`date_created` timestamp not null default current_timestamp,
`updated_by` int not null,
`date_updated` timestamp not null,
constraint organization_pk primary key (`organization_id`),
key `organization_ix` (`organization_id`)
) engine=innodb;
INSERT INTO `organization` (`organization_id`,`organization_name`,
`is_active`,`address_line1`,`address_line2`,`city`,`state`,`country`,
`zipcode`,`telephone_country_code`,`telephone_area_code`,
`telephone`,`mobile_country_code`,`mobile`,`fax_country_code`,
`fax_area_code`,`fax`,`url`,`created_by`,`date_created`,`updated_by`,
`date_updated`) VALUES (1,’Christian Medical Hospital’,1,’R.T.Nagar’,”,
‘Bangalore’,'Karnataka’,'India’,’560032′,91,80,23544328,0,0,0,0,0,
‘www.cmc.com’,1,’2009-11-12 00:00:00′,1,’2009-11-12 00:00:00′);