Features PhpStorm

Working with Windows Azure SQL Database in PhpStorm

PhpStorm provides us the possibility to connect to Windows Azure SQL Database right from within the IDE. In this post, we’ll explore several options that are available for working with Windows Azure SQL Database (or database systems like SQL Server, MySQL, PostgreSQL or Oracle, for that matter):

  • Setting up a database connection
  • Creating a table
  • Inserting and updating data
  • Using the database console
  • Generating a database diagram
  • Database refactoring

If you are familiar with Windows Azure SQL Database, make sure to configure the database firewall correctly so you can connect to it from your current machine.

Setting up a database connection

Database support can be found on the right-hand side of the IDE or by using the Ctrl+Alt+A (Cmd+Alt+A on Mac) and searching for “Database”.

Opening the database pane, we can create a new connection or Data Source. We’ll have to specify the JDBC database driver to be used to connect to our database. Since Windows Azure SQL Database is just “SQL Server” in essence, we can use the  SQL Server driver available in the list of drivers. PhpStorm doesn’t ship these drivers but a simple click (on “Click here”) fetches the correct JDBC driver from the Internet.

Next, we’ll have to enter our connection details. As the JDBC driver class, select the com.microsoft.sqlserver.jdbc driver. The Database URL should be a connection string to our SQL Database and typically comes in the following form:


The username to use comes in a different form. Due to a protocol change that was required for Windows Azure SQL Database, we have to suffix the username with the server name.

After filling out the necessary information, we can use the Test Connection button to test the database connection.

Congratulations! Our database connection is a fact and we can store it by closing the Data Source dialog using the Ok button.

Creating a table

If we right click a schema discovered in our Data Source, we can use the New | Table menu item to create a table.

We can use the Create New Table dialog to define columns on our to-be-created table. PhpStorm provides us with a user interface which allows us to graphically specify columns and generates the DDL for us.

Clicking Ok will close the dialog and create the table for us. We can now right-click our table and modify existing columns or add additional columns and generate DDL which alters the table.

Inserting and updating data

After creating a table, we can insert data (or update data from an existing table). Upon connecting to the database, PhpStorm will display a list of all tables and their columns. We can select a table and press F4 (or right-click and use the Table Editor context menu).

We can add new rows and/or edit existing rows by using the + and  buttons in the toolbar. By default, auto-commit is enabled and changes are committed automatically to the database. We can disable this option and manually commit and rollback any changes that have been made in the table editor.

Using the database console

Sometimes there is no better tool than a database console. We can bring up the Console by right-clicking a table and selecting the Console menu item or simply by pressing Ctrl+Shift+F10 (Cmd+Shift+F10 on Mac).

We can enter any SQL statement in the console and run it against our database. As you can see from the screenshot above, we even get autocompletion on table names and column names!

If we have multiple tables with foreign keys between them, we can easily generate a database diagram by selecting the tables to be included in the diagram and selecting Diagrams | Show Visualization… from the context menu or using the Ctrl+Alt+Shift+U (Cmd+Alt+Shift+U on Mac).

As you can see from the above screenshot, PhpStorm will generate a database diagram for the selected tables, displaying how they relate to each other.

Database refactoring

Renaming a table or column often is tedious. PhpStorm includes a Rename refactoring (Shift-F6) which generates the required SQL code for renaming tables or columns.

As we’ve seen in this post, working with Windows Azure SQL Database is pretty simple from within PhpStorm using the built-in database support.

Develop with pleasure!

– JetBrains Web IDE Team

Comments below can no longer be edited.

8 Responses to Working with Windows Azure SQL Database in PhpStorm

  1. Avatar

    Martin says:

    April 3, 2013

    Hi Martin,

    Can you make this available to Web Storm as well? I have seen the database navigator plugin but that seems to be mysql, oracle only.


  2. Avatar

    Maarten Balliauw says:

    April 3, 2013

    Hi Martin,

    Can you create a request on http://youtrack.jetbrains.com/issues/WEB ?

    Best regards

  3. Avatar

    Ibrahima Ciss says:

    April 16, 2013


    Thank you for this post! I work with SQL Server 2012 and I try to connect to it using PHPStorm6 but it does not connect.

    I followed steps described above but it seems to work only for Windows Azure.

    Any help would be great.

    Thank you 🙂

    • Avatar

      Maarten Balliauw says:

      April 17, 2013

      What isthe JDBC connection string you are using? (feel free to leave out the password :-))

      • Avatar

        Ibrahima Ciss says:

        April 17, 2013

        Hi Maarten,

        When I connect to my database using PHP & PDO for instance i type this:
        try {
        $db = new PDO(‘sqlsrv:Server=WIN-ELP7D85CNPU;Database=mydatabase’ , ‘myusername’ , ‘mypassword’);
        } catch ( PDOException $e ) {
        die (‘Connexion Failed’ . $e->getMessage());

        Thank you for your help 🙂

        • Avatar

          Maarten Balliauw says:

          April 17, 2013

          Can you try jdbc:sqlserver://WIN-ELP7D85CNPU;daabaseName=mydatabase;user=myusername;passwordmypassword ?

          • Avatar

            Ibrahima Ciss says:

            April 18, 2013

            Hi Maarten,

            Thank you so much, I do what you said and it’s working perfectly.

            You proved once again that PHPStorm is the PHP BEST IDE in the market.

            Best Regards 🙂

Discover more