Working with Tables and Indexes in Rider

In previous blog posts in this series, we looked at connecting to a Microsoft SQL Server and getting familiar with the features in Rider to work with SQL databases. In this blog post, we will look at how to work with a database to create tables and indexes.

This post is part of a series around working with databases and data in Rider:

(Note: we’ll use the Visual Studio keymap on Windows throughout this post – check the web help for Mac OS X and other keyboard schemes)

Creating/Modifying a Table

To create or work with existing tables in your database, you will need to open the View | Tools Windows | Database menu selection to view the details of your database or use Ctrl+T or a double Shift and then type “database” to get the window.

Expand the tables view in the Database window and right click to create a new table.

create a new table

The Create New Table dialog will be presented to work in the new table.

Create New Table dialog

You can create the columns, keys (including primary), indices and foreign keys by using the tabs and commands on the right border. The Action of the dialog with either allows the table to be immediately created in the connected database or to return the SQL script for the created table back in the Database Console. To finally create the table, execute the SQL script in the console.

return the SQL script for the created table back in the Database Console

Working with an existing table is through right-clicking the table in the Database windows or use the Ctrl+F6 keyboard shortcut.

Working with an existing table

In the Modify Table dialog, to edit a column double-click the row.

Modify Table dialog

After changing the table, you can either immediately update the table or save the script back to the Database Console just like when creating a new table.

Deleting a Table

Deleting or dropping a table from your database is performed by right-clicking the table and performing the Drop command or pressing the Delete key.

Deleting or dropping a table

Working with Primary and Foreign Keys

The column that identifies your primary key in your table is set up through the Modify or Create New Table dialogs. Checking the Primary key checkbox and then executing will identify the column as the unique key for the table.

Checking the Primary key checkbox

Working with foreign keys is also performed through the Modify or Create New dialogs. The list of foreign keys is on the Foreign Keys tab. Creating a new one through the Add command or Ctrl+N.

Working with foreign keys

You are then able to create the name of foreign key, identify the target table, choose your update and delete rule types and finally, the keys to join in the target table from the table.

Creating foreign keys

Working with Indexes

Working with Indexes or Indices of a table is performed in Indices tabs. Notice that there could be an index if you have created a primary key in the table. Create a new index using the Add command or Ctrl+N.

Working with Indexes or Indices of a table

After creating a new index, you can update the name, the uniqueness and the column(s) with sorting on each column in the index.

Naming Indexes or Indices of a table

Generating a Database Diagram

To view the Database Diagram while you are working with your database, perform the keyboard shortcut Ctrl+Alt+U.

View the Database Diagram

Wrap Up

Rider has a very rich and powerful set of data features that we have reviewed in this third part of the series. In our next post, we will look at how to use Rider to work with the data inside your tables, and other advanced topics.

Download Rider 2017.3 and give it a go! We’d love to hear your feedback!

This entry was posted in How-To's and tagged , , , . Bookmark the permalink.

2 Responses to Working with Tables and Indexes in Rider

  1. Smad says:

    “Generating a Database Diagram” In my rider is absent such feature
    https://www.screencast.com/t/yeKVQnvEgt

    As i know this feature only in Datagrip (Ctrl+Alt+U/Ctrl+Alt+Shift+U)

Leave a Reply

Your email address will not be published. Required fields are marked *