使用sql进行表迁移,无需使用JSP、PHP等编程语言

发布于 2024-10-05 22:32:15 字数 427 浏览 0 评论 0原文

我有三个表,

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

我想做迁移,那就需要在 tblstockinoutrtnstats 中插入 Stockin 计数,

我的详细信息是,

即从 tblstock 表中提取的 Productcode,tblstockhistory 表中存在的产品数量,

是否可以单独使用 sql 进行迁移不使用 PHP、JSP 等编程语言?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜`诱少女 2024-10-12 22:32:15

绝对地。

查询:
您将需要使用 ALTER TABLE 查询。根据您使用的 SQL 类型(SQLite、MySQL、PostgreSQL 等),该语句可能看起来略有不同,但基本命令类似于 ALTER TABLE table_name ADD column_name data_type; ( http://www.w3schools.com/sql/sql_alter.asp

没有语言:
我所知道的所有 SQL 风格都允许您在命令行上运行 SQL 查询。同样,根据您使用的口味,它会略有不同。
如果您使用的是 postgres,请输入 psql; <用户名>
如果您使用的是 MySQL,请输入 mysql -U <用户名>;
如果您使用的是另一个版本的 SQL,请查看他们的帮助和/或手册页,了解该特定风格所需的确切语法。

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.

夜光 2024-10-12 22:32:15

是的,这是可能的。使用 MySQL 和大多数其他数据库,您可以编写 SQL,将其存储在文本文件中,并由数据库作为批处理运行。在 MySQL 中,它非常简单,链接 https:// dev.mysql.com/doc/refman/5.7/en/mysql-batch-commands.html 展示了如何操作。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文