Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 2.02 KB

File metadata and controls

29 lines (20 loc) · 2.02 KB
title Using a SQL statement to modify database objects
description Using a SQL statement to modify database objects
author David-Engel
ms.author davidengel
ms.date 08/12/2019
ms.service sql
ms.subservice connectivity
ms.topic how-to

Using a SQL statement to modify database objects

[!INCLUDEDriver_JDBC_Download]

To modify [!INCLUDEssNoVersion] database objects by using a SQL statement, you can use the executeUpdate method of the SQLServerStatement class. The executeUpdate method will pass the SQL statement to the database for processing, and then return a value of 0 because no rows were affected.

To do this, you must first create a SQLServerStatement object by using the createStatement method of the SQLServerConnection class.

Note

SQL statements that modify objects within a database are called Data Definition Language (DDL) statements. These include statements such as CREATE TABLE, DROP TABLE, CREATE INDEX, and DROP INDEX. For more information about the types of DDL statements that are supported by [!INCLUDEssNoVersion], see [!INCLUDEssNoVersion] Books Online.

In the following example, an open connection to the [!INCLUDEssSampleDBnormal] sample database is passed in to the function, a SQL statement is constructed that will create the simple TestTable in the database, and then the statement is run and the return value is displayed.

[!codeJDBC#UsingSQLToModifyDBObjects1]

See also

Using statements with SQL