Bharanikumar Bharanikumar - 25 days ago 6
MySQL Question

table migration with sql without using programming language like JSP, PHP

I have three table,


tblstock --> StockID(Primary Key),ProductCode,Status,
tblstockhistory --> StockID(tblstock table StockID, 1:N),Qty,invoceNo,MRP
tblstockinoutrtnstats --> StatsID,ProductCode,StockIN


i want to do the migration,That is need insert the Stockin countin tblstockinoutrtnstats ,

my details are,

that is Productcode pull from tblstock table,product quantity present in tblstockhistory table,

Is it possible to do the migration with sql alone without using programming langugage like PHP,JSP ?

Answer

Absolutely.

Query:
Your going to want to use an ALTER TABLE query. Depending on what flavor of SQL you're using (SQLite, MySQL, PostgreSQL, etc.) the statement might look slightly different, but the basic command will be similar to ALTER TABLE table_name ADD column_name data_type; (http://www.w3schools.com/sql/sql_alter.asp)

Without a Language:
All flavors of SQL I know of allow you to run SQL queries on the command line. Again, it will be slightly different depending on the flavor you're using.
If you're using postgres, type psql <db_name> <username>
If you're using MySQL, type mysql -U <username> <db_name>
If you're using another version of SQL, look at their help and/or man page to see what the exact syntax you need is for that specific flavor.