SQL Database Management Portal
Total Page:16
File Type:pdf, Size:1020Kb
APPENDIX A SQL Database Management Portal This appendix introduces you to the online SQL Database Management Portal built by Microsoft. It is a web-based application that allows you to design, manage, and monitor your SQL Database instances. Although the current version of the portal does not support all the functions of SQL Server Management Studio, the portal offers some interesting capabilities unique to SQL Database. Launching the Management Portal You can launch the SQL Database Management Portal (SDMP) from the Windows Azure Management Portal. Open a browser and navigate to https://manage.windowsazure.com, and then login with your Live ID. Once logged in, click SQL Databases on the left and click on your database from the list of available databases. This brings up the database dashboard, as seen in Figure A-1. To launch the management portal, click the Manage icon at the bottom. Figure A-1. SQL Database dashboard in Windows Azure Management Portal 257 APPENDIX A N SQL DATABASE MANAGEMENT PORTAL N Note You can also access the SDMP directly from a browser by typing https://sqldatabasename.database. windows.net, where sqldatabasename is the server name of your SQL Database. A new web page opens up that prompts you to log in to your SQL Database server. If you clicked through the Windows Azure Management Portal, the database name will be automatically filled and read-only. If you typed the URL directly in a browser, you will need to enter the database name manually. Enter a user name and password; then click Log on (Figure A-2). Figure A-2. SQL Database Manage Portal login screen 258 APPENDIX A N SQL DATABASE MANAGEMENT PORTAL Once logged on, you will see a page similar to Figure A-3, which defaults to the administration summary page of the database instance, giving you general information about your database instance such as its free space, current connections, and more. You can also access the design page, a section of the portal that allows you to manage tables, views, and stored procedures. The administration and design features are explained next. Figure A-3. Administration Summary screen Administration Features The administration section of the portal allows you to manage your federations, monitor current query performance, and run T-SQL queries and optionally view their execution plans. Chapter 10 covered federations at length, so this appendix will focus on the other administration features. Run T-SQL Statements Let’s first run a T-SQL statement and look at the options available to us. From the administration Summary page, click the New Query icon on top of the page. This opens up a new query window. You can open as many windows as needed to run multiple queries as you would in SQL Server Management Studio. Type and execute the following statement (click the Run icon to execute it): SELECT * FROM sys.tables Running this query returns the list of tables currently found in your database. The query window and its result are shown in Figure A-4. The output shows you a grid containing the fields as columns and a row for each table. A scrollbar shows up on the right if needed. Between the query window and results area, two links are provided: Messages and Results. The Results link is selected by default (it has a little downward arrow on top of it). Clicking on Messages will shows you any associated message for the query, including any error messages. As in the SQL Server Management Studio, if an error is found, the Messages window would be shown by default instead of the Results window. 259 APPENDIX A N SQL DATABASE MANAGEMENT PORTAL Figure A-4. The Query window and results area N Note You can use the splitter in the middle of the screen, between the query window and the results area, to adjust the visible area as desired. Note that you can run multiple queries from the same window as well. For example, execute the following batch: SELECT * FROM sys.tables SELECT * FROM sys.procedures You may notice that the results area of the page only shows the list of tables, just as in Figure A-4. However if you click on the Rows summary (Figure A-5), you’ll see a drop-down list with the complete list of result sets, one for each statement in the batch. If you click the second item, assuming your database has stored procedures, you will see the result set for the second statement in the batch. You may also notice a visual cue in the drop-down list, indicating the relative number of records returned by each statement in the batch. Because the second statement returned 6 rows out of a total of 21 in the batch, the second item in the list contains a bar filled at about 25% of the length of the item. Figure A-5. Switching the Results view 260 APPENDIX A N SQL DATABASE MANAGEMENT PORTAL View Execution Plans You can also view either an estimated execution plan or the actual plan from the same query window. The Actual Plan and Estimated Plan icons are next to the Run icon you clicked previously. With the same two T-SQL statements entered previously, click the Actual Plan icon. When the execution is finished, you will notice a Query Plan link next to Results. Click on this link; you will see the execution plan shown in Figure A-6. Figure A-6. Viewing the actual execution plan The Sort By icons on the left allow you to pinpoint which operators consume the most resources. By default, the execution plan shows a graphical display highlighting the operators that consume the most CPU and I/O resources. You can click on the CPU or IO icon on the left to show the operators that consume the most CPU or I/O resources, respectively. The Find By icons on the left allow you to highlight execution warnings, index scans, or index seeks. Note that table scans cannot exist, because SQL Database does not support heap tables. You can also zoom in or out easily using the vertical bar on the bottom left. Doing so changes the display of the icons when you zoom in enough, as shown in Figure A-7. 261 APPENDIX A N SQL DATABASE MANAGEMENT PORTAL Figure A-7. Zooming in on the Actual execution plan If you switch the active statement from the batch (as previously shown in Figure A-5), the execution plan for the second statement will be displayed. You can also display the execution plan in a grid or a tree by clicking the appropriate icon on the top right of the execution plan window. Monitor Current Query Performance To view the statements recently executed on your database, select the database name on the left panel (EnzoLog2 in my example). This will bring you back to a page similar to Figure A-3., where you choose Query Performance on the top. A page similar to Figure A-8 will appear, showing the list of recent statements that were executed against the database with summary performance metrics. Note that these metrics show averages, not the current values. For example, the second column displays CPU ms/sec, which is an average of CPU consumption in millisecond over the duration of the session, expressed in seconds. Figure A-8. Recent T-SQL statements executed against your database 262 APPENDIX A N SQL DATABASE MANAGEMENT PORTAL If you click on one of the statements, you will see detailed performance metrics. By default the page shows you the Query Plan Details, including duration, CPU, read, write and plan metrics (see Figure A-9). You can also view the graphical execution plan by clicking on Query Plan. Figure A-9. Performance details for a specific T-SQL statement Design Features The design section of the portal allows you to manage database objects, including tables, views, and stored procedures. As you will see, the design section offers many advanced graphical options, including the ability to create indexes and foreign keys. Designing Tables To access the design section, click Design at the bottom left of the portal. Notice that the top section of the resulting page shows you three headers: Tables, Views, and Stored Procedures. By default the Tables header is selected, and the page shows you the list of existing tables, as seen in Figure A-10. Using the icons on the bottom of this page you can create a new table or drop a selected existing table. You can also filter the list of tables by typing characters in the search box. 263 APPENDIX A N SQL DATABASE MANAGEMENT PORTAL Figure A-10. List of tables in a SQL Database instance The page used to create a new table is identical to the one used to edit an existing table. You’ll see how to edit a table shortly, but let’s look at the Dependencies feature first. Two icons (Edit and Dependencies) automatically appear if you move your mouse over the list of tables. The Edit icon looks like a small pencil. The other icon is the Dependencies icon. If you click on the Dependencies icon for a table, a new page will be displayed, showing its object dependencies in a graphical format, as seen for my DOCS table in Figure A-11. The graph shows me that a view called v_Documents depends on my DOCS table. From this view I can directly edit these objects by clicking on their Edit icons. 264 APPENDIX A N SQL DATABASE MANAGEMENT PORTAL Figure A-11.