tailieunhanh - Oracle Database Administration for Microsoft SQL Server DBAs part 14

Oracle Database Administration for Microsoft SQL Server DBAs part 14 takes the administration topics with which the SQL Server DBA is familiar, translates them into Oracle terms, and then expands on Oracle functionality. Definitions and comparative terms run throughout the book so the SQL Server DBA can easily leverage existing knowledge. This Oracle Press guide also expands on some of the features in Oracle that do not match up directly with SQL Server, and looks at other processes often performed on an Oracle database that would not typically be a standard practice in SQL Server environments | 112 Oracle Database Administration for Microsoft SQL Server DBAs FIGURE 5-3. Enterprise Manager Configuration Administrators section SQL Plus If you created a database in the Linux environment you have already used SQL Plus. With Windows versions before Oracle Database 11 g SQL Plus was a simple graphical interface for entering SQL statements. With 11 g running SQL Plus opens a command-line window for executing queries. Figure 5-4 shows the new and previous versions. FIGURE 5-4. SQL Plus in Oracle Database 11g left and 10g right Chapter 5 DBA Tools 113 You may be thinking Oh no not command line How can I go from a nice graphical interface to using a command-line tool It is not as bad as you might think. SQL Plus is handy for queries such as a quick check or count and also to incorporate into scripts. Consider how you might use SQL Server sqlcmd or osql to run a query or for scripting. For example here s how you would pass in a SQL statement and capture the output of the statement in a log file with osql f osql -U userl -P userpasswd -i -o In Oracle with SQL Plus you can do this as follows f sqlplus user2 userpasswd So now you are probably wondering where the sp_who and sp_who2 commands are in Oracle because they would be useful for a quick check from the command line. Well there is not really an sp_who command but here s a query that will provide the same results SQLPLUS SELECT from v session s v sql t where and USER USERNAME SCHEMANAME STATUS PROCESS SQL_TEXT MMTEST MMTEST INACTIVE 5840 5140 select cust_name You can put this query in a package or procedure to create your own version. Using the command line in scripts or batch files is very useful. You can write the results of a query to file and if you re using the results to create new SQL commands these files can then be executed. The spool command used with a file name will write the .