Databases

A database is a collection of tables, views, stored procedures, indexes, and other objects that store and manage a specific set of structured data.

In Database Explorer, you can manage databases by using the shortcut menu. Right-click a database in Database Explorer to access options for specific tasks, such as creating or editing a database, source-controlling a database, running data operations, backing up or restoring operations.

Create a database

1. In Database Explorer, right-click a database or a server connection and select New Database.

2. In Database Editor, specify the database details.

3. At the bottom of Database Editor, click Apply Changes to save the database.

Edit a database

1. In Database Explorer, right-click the database you want to edit and select Edit Database.

2. In Database Editor, update the database details.

Note

You cannot update a database name.

3. At the bottom of Database Editor, click Apply Changes to save and apply the changes made to the database.

Delete a database

1. In Database Explorer, right-click the database you want to delete and select Delete, or press Delete.

2. Click OK to confirm the deletion of the database.

Note

You cannot undo the drop database operation, as this action permanently deletes all data and the database structure. It is recommended that you back up the database before deleting it.

Create a database object

1. In Database Explorer, right-click the database and select New Object, then select an object type, for example, Table, View.

Perform operations on database objects

2. Specify the object details in the corresponding Object Editor, for example, Table Editor or View Editor.

Note

Object Editor varies based on the selected object type.

3. At the bottom of Object Editor, click Apply Changes to save and apply the changes made to the database.

Link a database to source control

dbForge Studio allows you to link databases to a source control repository in the following systems:

  • Subversion (SVN)
  • Microsoft Azure DevOps (Team Foundation Version Control (TFVC))
  • Git (including GitHub, GitLab, BitBucket, Azure DevOps)
  • Perforce (P4)
  • Mercurial
  • SourceGear Vault

To link a database to a repository:

1. In Database Explorer, right-click the database you want to link and select Source Control > Link Database to Source Control.

2. In the Link Database to Source Control dialog, configure the repository settings.

3. Depending on the source control system you want to link to, follow the steps from the corresponding topics:

  • Link a database to a Git repository:
    • GitHub
    • Azure DevOps
    • BitBucket
    • GitLab
  • Link a database to TFVC
  • Link a database to SVN
  • Link a database to SourceGear Vault
  • Link a database to a Perforce repository
  • Link a database to a Mercurial repository
  • Link a database to Plastic SCM and other systems

4. In the Link Database to Source Control dialog, select the database development model.

5. Click Link.

Find an object

1. In Database Explorer, right-click the database where you want to search for an object and select Find Object, or press Ctrl+D, F.

2. In the Search window, switch to the Search objects by name and DDL mode and enter the search string.

3. Follow the steps from How to search for database objects.

Shortcut menu options

The following table describes the shortcut menu options, which appear when you right-click a database in Database Explorer.

Name Description
New SQL Opens a new SQL document.
New Object > Table Opens Table Editor to create and modify a table.
New Object > View Opens View Editor to create and manage a view.
New Object > Synonym Opens the SQL document with the CREATE SYNONYM statement template.
New Object > Table-valued Function Opens the SQL document with the CREATE FUNCTION statement template.
New Object > Scalar Function Opens the SQL document with the CREATE FUNCTION statement template.
New Object > Aggregate Function Opens the SQL document with the CREATE AGGREGATE statement template.
New Object > Procedure Opens the SQL document with the CREATE PROCEDURE statement template.
New Object > Sequence Opens the SQL document with the CREATE SEQUENCE statement template.
New Object > DDL Trigger Opens the SQL document with the CREATE TRIGGER statement template.
New Database Opens Database Editor to create a database.
Edit Database Opens Database Editor to edit a database.
Source Control > Link to Source Control Opens the Link Database to Source Control dialog to connect a database to a source control system.
Tasks > Back Up Opens the Backup wizard to make a backup of the selected database.
Tasks > Restore Opens the Restore wizard to restore a database backup or copy the database from one server to another.
Tasks > Detach Database Opens the Detach Database dialog to detach a database in SQL Server.
Tasks > Copy Database Opens the Copy Database dialog to copy a database from one SQL Server database engine to another.
Tasks > Take Offline Temporarily disconnects a database from the SQL Server instance.
The Take Offline option is unavailable if the database is already offline.
Tasks > Bring Online Reconnects a disconnected database in the SQL Server instance.
The Bring Online option is unavailable if the database is already online.
Tasks > Generate Scripts Opens the Generate Scripts Wizard to generate a database script.
Tasks > Create Scripts Folder or Snapshot Open the Create Scripts Folder or Snapshot dialog to create a scripts folder or a database snapshot.
Tasks > Find Invalid Objects Opens the Find Invalid Objects document to search for invalid objects in multiple databases.
Shortcut: Ctrl+Alt+F.
Tasks > New Schema Comparison Opens the New Schema Comparison dialog to set up and run schema comparison.
Tasks > New Data Comparison Opens the New Data Comparison dialog to set up and run data comparison.
Tasks > Export Data Opens the Data Export wizard to export data to a file with the supported file extension.
Tasks > Import Data Opens the Data Import wizard to import data from a file into a database.
Tasks > New Data Generation Opens the Data Generator Project Properties dialog, where you can configure data generation settings and generate test data for the database.
Tasks > New Documentation Opens the Database Documenter project to generate a database documentation file (.ddoc).
Tasks > Manage Database Encryption Opens the Manage Database Encryption dialog to configure Transparent Data Encryption (TDE) for a database.
Tasks > Manage Index Fragmentation Opens the Index Manager document to analyze SQL indexes by collecting index fragmentation statistics and detecting databases that require maintenance.
Unit Test > Add New Test Opens the Add New Test dialog to create a unit test for a specific database.
Unit Test > View Test List Opens the Test List Manager to view unit tests in the database.
Unit Test > Run All Tests Runs all tests for the selected database and displays test results in the Test Results pane.
Unit Test > Install Test Framework Opens the Install Test Framework dialog to install a test framework.
Unit Test > Uninstall Test Framework Uninstalls the selected test framework.
Generate Script As Generates a script of the selected database using the CREATE, DROP, and DROP and CREATE statements. The script can be saved to a new SQL document or a file, or copied to the clipboard.
Find Object Opens the Search window to search for database objects.
Shortcut: Ctrl+D, F
Show Details Opens Object Viewer that displays object details.
Delete Deletes all data and the database structure.
Shortcut: Delete
Refresh Updates the object to reflect the latest changes.
Shortcut: F5
Properties Opens the Properties pane to view the object information.
Shortcut: F4

Bulk operations

In Database Explorer, hold down Ctrl and select multiple databases. Then right-click the selection and select the required option.

The following table describes the shortcut menu options available for multiple databases.

Name Description
Edit Database Opens Database Editors for each selected database.
Tasks > Detach Database Opens the Detach Database dialog to detach the selected databases.
Tasks > Copy Database Opens the Copy Database dialog to copy the selected databases from one SQL Server database engine to another.
Tasks > Take Offline Temporarily disconnects the selected databases from the SQL Server instance.
The Take Offline option is available only when all selected databases are online.
Tasks > Bring Online Reconnects the selected disconnected databases to the SQL Server instance.
The Bring Online option is available only when all selected databases are offline.
Tasks > Find Invalid Objects Opens the Find Invalid Objects document to search for invalid objects in the selected databases.
Shortcut: Ctrl+Alt+F.
Tasks > New Schema Comparison Opens the New Schema Comparison dialog to set up and run schema comparison.
Tasks > New Data Comparison Opens the New Data Comparison dialog to set up and run data comparison.

Note

The New Schema Comparison and New Data Comparison options are available only when you select two databases. These options can also be used for the databases that reside on different servers.

Bulk operations for multiple databases