开发者

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 tblstoc开发者_如何学Pythonkhistory table,

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


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.


Yes this is possible. With MySQL and most other databases you can write your SQL, store it in a text file and have it run as a batch by the database. In MySQL it's very simple and the link https://dev.mysql.com/doc/refman/5.7/en/mysql-batch-commands.html shows your how to do it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜