大网数据广告活动
安装更新与部署

Examples of Database Queries Using SQL and Script

· 52CE 我爱测

An example of using script-driven database queries is provided in the Windows Installer Software Development Kit (SDK) as the utility WiRunSQL.vbs.

An example of using script-driven database queries is provided in the Windows Installer Software Development Kit (SDK) as the utility WiRunSQL.vbs. This utility handles database queries using the Windows Installer version of SQL described in the section SQL Syntax.

Delete a record from a table

The following command line deletes the record having the primary key RED from the Feature table of the Test.msi database.

Cscript WiRunSQL.vbs Test.msi "DELETE FROM `Feature` WHERE `Feature`.`Feature`='RED'"

Add a table to a database

The following command line adds the Directory table to the Test.msi database.

CScript WiRunSQL.vbs Test.msi "CREATE TABLE `Directory` (`Directory` CHAR(72) NOT NULL, `Directory_Parent` CHAR(72), `DefaultDir` CHAR(255) NOT NULL LOCALIZABLE PRIMARY KEY `Directory`)"

Remove a table from a database

The following command line removes the Feature table from the Test.msi database.

Cscript WiRunSQL.vbs Test.msi "DROP TABLE `Feature`"

Add a new column to a table

The following command line adds the Test column to the CustomAction table of the Test.msi database.

CScript WiRunSQL.vbs Test.msi "ALTER TABLE `CustomAction` ADD `Test` INTEGER"

Insert a new record into a table

The following command line inserts a new record into the Feature table of the Test.msi database.

Cscript WiRunSQL.vbs Test.msi "INSERT INTO `Feature` (`Feature`.`Feature`,`Feature`.`Feature_Parent`,`Feature`.`Title`,`Feature`.`Description`, `Feature`.`Display`,`Feature`.`Level`,`Feature`.`Directory_`,`Feature`.`Attributes`) VALUES ('Tennis','Sport','Tennis','Tournament',25,3,'SPORTDIR',2)"

This inserts the following record into the Feature table of Test.msi.

Feature Table

Feature Feature_Parent Title Description Display Level Directory_ Attributes
Tennis Sport Tennis Tournament 25 3 SPORTDIR 2

Note that binary data cannot be inserted into a table directly using the INSERT INTO or UPDATE SQL queries. For information see Adding Binary Data to a Table Using SQL.

Modify an existing record in a table

The following command line changes the existing value in the Title field to "Performances." The updated record has "Arts" as its primary key and is in the Feature table of the Test.msi database.

Cscript WiRunSQL.vbs Test.msi "UPDATE `Feature` SET `Feature`.`Title`='Performances' WHERE `Feature`.`Feature`='Arts'"

Select a group of records

The following command line selects the name and type of all controls that belong to the ErrorDialog in the Test.msi database.

CScript WiRunSQL.vbs Test.msi "SELECT `Control`, `Type` FROM `Control` WHERE `Dialog_`='ErrorDialog' "

Hold a table in memory

The following command line locks the Component table of the Test.msi database in memory.

CScript WiRunSQL.vbs Test.msi "ALTER TABLE `Component` HOLD"

Free a table in memory

The following command line frees the Component table of the Test.msi database from memory.

CScript WiRunSQL.vbs Test.msi "ALTER TABLE `Component` FREE"

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。