顯示具有 sql 標籤的文章。 顯示所有文章
顯示具有 sql 標籤的文章。 顯示所有文章

2012/04/20

1Z0-042 7p20q

1Z0-042

1.You have a text file that maintains information on thousands of items. The end-user application requires
the transfer of that information into a table in the database. What would you use to achieve this task?
(Choose two.)
A. Data Pump
B. SQL*Loader
C. External table
D. Oracle Text
E. Oracle Import
Answer: BC

2.Which step do you need to perform to enable a user with the SYSDBA privilege to log in as SYSDBA in
iSQL*Plus.?
A. The user must be granted the database administrator (DBA) privilege.
B. Set up a user in the Oracle Application Server Containers for J2EE (OC4J) user manager, and grant
the webDba role to the user.
C. The user must be listed in the password file for the authentication.
D. No special setup is needed for the user to connect as SYSDBA in iSQL*Plus.
Answer: B

3.You specified extent management as local for a tablespace. How will it affect space management in the
tablespace?
A. The tablespace will be system managed and the users cannot specify the extent size.
B. Free extents will be managed by the data dictionary tables.
C. All the extents will be of the same size.
D. Bitmap will be used to record free and allocated extents.
Answer: D

4.Which two operations require undo data? (Choose two.)
A. recovering from failed transactions
B. recording a transaction to redo log files
C. rolling back a transaction
D. committing a transaction
E. rolling forward during instance recovery
Answer: AC

5.The employee IDs of employees who have made sales in the company are transferred from the
EMPLOYEES table to the BONUS table with a default bonus value. Later, the human resources
department decides to give bonuses to employees as per the following conditions:
1. Employees with a salary of $8,000 or less should receive a bonus.
2. Employees who have not made sales get a bonus of 1% of their salary.
3. Employees who already made sales get an increase in their bonus equal to 1% of their salary.
What would you do to implement these changes in one step?
A. Use SQL*Loader utility.
B. Use the MERGE statement.
C. Use a multitable insert operation.
D. Use a correlated UPDATE statement.
Answer: B

6.The ST_INFO master table has millions of rows that are updated very rarely. It has a STATE_CODE
column that contains the value for 25 states. The table is frequently queried on the STATE_CODE column.
Which type of index would you suggest to improve the query performance?
A. bitmap
B. B-tree
C. function based
D. reverse key
Answer: A

7.You want to monitor and control the resource usage by sessions. You want to be warned automatically
when more than 100 sessions are opened with your database. What action would you take to achieve
this?
A. Set the warning threshold for the Current Logons Count metric.
B. Set the limits in the profiles used by users.
C. Use the Database Resource Manager.
D. Modify the SESSIONS initialization parameter.
Answer: A

8.User Scott has updated the salary of one of the employees in the EMPLOYEES table and has not
committed the transaction. What are the two types of locks that this scenario would lead to? (Choose
two.)
A. a shareable table lock for the table containing the row
B. null lock on the table containing the row
C. exclusive table-level lock for the table containing the row
D. null lock on the row being updated
E. ROW SHARE lock for the row being updated
F. shared row-exclusive lock for the row being updated
G. ROW EXCLUSIVE lock for the row being updated
Answer: AG

9.Which statement regarding the contents of the V$PARAMETER view is true?
A. displays only the list of default values
B. displays the current contents of the server parameter file
C. displays the currently in effect parameter values
D. displays the list of all the parameter files of a database
E. displays only the list of all advanced parameters
F. displays only the list of all basic parameters
Answer: C

10.Redo log files are not multiplexed in your database. Redo log blocks are corrupted in group 2, and
archiving has stopped. All the redo logs are filled and database activity is halted. Database writer has
written everything to disk. Which command would you execute to proceed further?
A. ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 2;
B. RECOVER LOGFILE BLOCK GROUP 2;
C. ALTER DATABASE CLEAR LOGFILE GROUP 2;
D. ALTER DATABASE DROP LOGFILE GROUP 2;
E. ALTER DATABASE RECOVER LOGFILE GROUP 2;
Answer: A

11.Which three statements are true regarding the fine-grained auditing (FGA)? (Choose three.)
A. FGA is possible on SELECT statements only.
B. The audit trail for FGA is stored in the AUD_LOG$ table.
C. FGA includes the SQL statement used by the user as part of the audit event entry.
D. FGA enables a SQL predicate to define when to audit an event.
E. The audit trail for FGA is stored in the FGA_LOG$ table.
F. FGA audits DELETE statements only when audit columns are specified.
Answer: CDE

12.Your database instance is started using the server parameter file (SPFILE). Control files are
multiplexed and stored on different disks. Because of a disk failure, you lost one of these control files. You
replaced the damaged disk. What is the correct sequence of steps that you would follow to recover the
control file?
1. Shut down the instance, if not already done.
2. Copy one of the remaining control files to a new location.
3. Change the value of the CONTROL_FILES initialization parameter to correspond to the new location of
the control files.
4. Start up the database instance to the NOMOUNT stage.
5. Recover the database to the point of failure of the control file.
6. Open the database.
A. 2,4,3,4,5
B. 5,2,3,4
C. 4,5,6,2,3
D. 1,2,4,3,5
Answer: D

13.You executed the STARTUP MOUNT command to start your database. For which database operation
do you need to start the database in the MOUNT state?
A. dropping a user in your database
B. dropping a tablespace in your database
C. enabling or disabling redo log archiving
D. renaming the control files
E. re-creating the control files, after you lost all the control files in your database
Answer: C

14.View the Exhibit to see the source and target databases.
You have created a database link, devdb.us.oracle.com, between the databases PRODDB and DEVDB.
You want to import schema objects of the HR user using Oracle Data Pump from the
development database, DEVDB, to the production database, PRODDB. You execute the following
command on the target database server:
$impdp system/manager directory = DB_DATA
dumpfile = schemas.dat
schemas = hr
flashback_time = 2004-02-03 09:00
The command fails, displaying the following error:
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-31640: unable to open dump file "/home/oracle/schema/schemas.dat" for read
ORA-27037: unable to obtain file status
What would you do to overcome the error?











A. remove the dumpfile option in the command
B. remove the flashback_time option in the command
C. remove the dumpfile option and add the network_link = devdb.us.oracle.com option in the command
D. add the user, SYSTEM, to the schemas option in the command
E. remove the schemas option and add the network_link = devdb.us.oracle.com option in the command
F. add network_link = devdb.us.oracle.com option in the command
Answer: C

15.You want to create a tablespace with the following specifications:
1. The tablespace extends automatically.
2. Used and free extents should be managed by bitmaps.
3. Default PCTUSED attribute is set to 60.
4. All the extents would be of size 1 MB.
Which three options would you choose to create the tablespace? (Choose three.)
A. tablespace with segment space management as automatic
B. tablespace with AUTOEXTEND enabled
C. tablespace with a uniform extent allocation of 1 MB
D. tablespace with dictionary-managed extents
E. tablespace with segment space management as manual
Answer: BCE

16.Examine the following commands executed in your database:
SQL> ALTER SESSION RECYCLEBIN=ON;
Session altered
SQL> CREATE TABLE emp TABLESPACE tbsfd AS SELECT * FROM hr.employees; Table created.
Further, you executed the following command to drop the table:
SQL> DROP TABLE emp;
Table dropped.
What happens in this scenario?
A. The table is moved to the SYSTEM tablespace.
B. The table is renamed and remains in the TBSFD tablespace.
C. The table is moved to the SYSAUX tablespace.
D. The table is removed from the database permanently.
Answer: B

17.Which two statements are true about the roles in the Oracle database? (Choose two.)
A. A role cannot be assigned external authentication.
B. Roles can be granted to other roles.
C. Roles are owned by the SYS user.
D. A role can be granted to itself.
E. A role can contain both system and object privileges.
Answer: BE

18.The user SCOTT executes the following command successfully to increase the salary values in one of
his sessions:
SQL> UPDATE emp SET sal=sal*1.15 WHERE deptno=20;
Before SCOTT ends the transaction, user HR who has the privileges on EMP table executes a query to
fetch the salary details but finds the old salary values instead of the increased values.
Why does HR still see the old data?
A. because of redo data from redo log file
B. because of data from a temporary tablespace
C. because of undo data from the undo tablespace
D. because of data from database buffer cache
Answer: C

19.In your database, the snapshot interval is set to 10 minutes for the Automatic Workload Repository
(AWR). The database instance is running for the past 30 days.
View the Exhibit to examine the Automatic Database Diagnostic Monitor (ADDM) task.
The ADDM task is performed every 10 minutes, except the last task. What could be the reason for this?










A. The snapshot retention period for the AWR was increased before the last task.
B. The STATISTICS_LEVEL initialization parameter was changed to BASIC and reset to TYPICAL before
the last task.
C. The optimizer statistics was collected manually by using the DBMS_STATS package before the last
task.
D. The optimizer statistics for few objects in the database were locked before the last task.
Answer: B

20.You plan to use static database registration for a new listener when you create it. What could be the
two reasons for this? (Choose two.)
A. The Oracle Enterprise Manager is to be used to monitor an Oracle9i database.
B. More than one database is to be registered with the listener.
C. The listener is not configured on the default port of 1521 and the instance is not configured to register
with a nondefault port.
D. The users will connect the database by using the host naming method.
E. The database that is to be registered with the listener is configured in shared server mode.
Answer: AC

2012/04/14

offical SQL Server sample

offical SQL Server sample
http://msftdbprodsamples.codeplex.com/releases/view/55926


Release Notes

Sample Databases for Microsoft SQL Server 2008R2 (SR1)

This release is dedicated to the sample databases that ship for Microsoft SQL Server 2008R2. See Database Prerequisites for SQL Server 2008R2 for feature configurations required for installing the sample databases. See Installing SQL Server 2008R2 Databases for step by step installation instructions.

The SR1 release contains minor bug fixes to the installer used to create the sample databases. There are no changes to the databases themselves. If you have already successfully installed the AdventureWorks 2008R2 sample databases there is no need to install AdventureWorks 2008R2 SR1. This release has been updated to correctly handle the situation where the default instance is the only instance available.

All of the AdventureWorks sample databases for SQL Server 2008R2 are included in the self extracting zip file. When this zip file is run, all content is unzipped to a temporary directory and an installer application is automatically started. This application copies the database scripts and data files to the directory specified, and optionally installs sample databases. If some databases cannot be installed, a brief explanation is displayed and a link is provided for more information about how to resolve the installation issues.

The analysis services databases must be deployed manually using SQL Server Business Intelligence Development Studio after installation is complete. Please see Installing Analysis Services Database for more details.

The latest installer which is now available has better support for instances with different version of SQL Server, and also includes both the AdventureWorks 2008R2 schemas and data files and the original AdventureWorks schemas and data files which shipped with SQL Server 2005. Installing both AdventureWorks families will ensure that all samples will work correctly and that you'll be able to explore the new features in SQL Server 2008.

Update
Some users have been unable to successfully install the AdventureWorks2008R2 OLTP database using the SR1 installer. We have added a version of the database without FILESTREAM as a single file that you can download and attach. To install this version, go to AdventureWorks2008R2 without filestream.

Please give us your feedback in the samples forum! (Yes, even the complaints. We do try to respond to them.)

2012/02/29

inner-join

#mySQL 5.0.5

multi-table

select
a.macd_id as midy1,a.macd_date as mdatey1,a.macd_r5 as r5y1,a.macd_r9 as r9y1,a.macd_r14 as r14y1,a.macd_ks9 as mks9y1,a.macd_ds9 as mds9y1,a.macd_dif1226 as mdif1226y1,a.macd_macd9 as macd9y1,
b.macd_id as midy2,b.macd_date as mdatey2,b.macd_r5 as r5y2,b.macd_r9 as r9y2,b.macd_r14 as r14y2,b.macd_ks9 as mks9y2,b.macd_ds9 as mds9y2,b.macd_dif1226 as mdif1226y2,b.macd_macd9 as macd9y2,
c.macd_id as midy3,c.macd_date as mdatey3,c.macd_r5 as r5y3,c.macd_r9 as r9y3,c.macd_r14 as r14y3,c.macd_ks9 as mks9y3,c.macd_ds9 as mds9y3,c.macd_dif1226 as mdif1226y3,c.macd_macd9 as macd9y3,
d.macd_id as midy4,d.macd_date as mdatey4,d.macd_r5 as r5y4,d.macd_r9 as r9y4,d.macd_r14 as r14y4,d.macd_ks9 as mks9y4,d.macd_ds9 as mds9y4,d.macd_dif1226 as mdif1226y4,d.macd_macd9 as macd9y4

from macd a join macd b, macd c join macd d

where a.macd_id=b.macd_id
and a.macd_id=c.macd_id
and a.macd_id=d.macd_id

and a.macd_date='2012-02-24'
and b.macd_date='2012-02-23'
and c.macd_date='2012-02-22'
and d.macd_date='2012-02-21'

and a.macd_dif1226<>''
and b.macd_dif1226<>''
and c.macd_dif1226<>''
and d.macd_dif1226<>''

and a.macd_r14<-70

limit 60

2011/12/29

update/replace column content

//mySQL

UPDATE [table_name]
set [column_name]=REPLACE([column_name], '[before]', '[after]')


UPDATE s_his
set s_his_date=REPLACE(s_his_date, 'Dec 7, 2011', '2011-12-07')





date calculation

//mySQL


SELECT CURDATE( )
-------------------
CURDATE( )
2011-12-29

SELECT CURDATE( ) -1
-------------------
CURDATE( ) -1
20111228

SELECT now( )
-------------------
now( )
2011-12-29 10:29:31

SELECT now( )-1
-------------------
now( )-1
20111229104426.000000

2011/12/24

SQL Language (Speed Test)

#Server version: 5.0.51b-community-nt-log
#MySQL client version: 5.0.51a
#Used PHP extensions: mysql

SELECT
s_day.s_day_id,
s_day.s_day_yesterday,
s_day.s_day_date,
s_bwibbu.s_bwibbu_id,
s_bwibbu.s_bwibbu_name,
s_bwibbu.s_bwibbu_per,
s_bwibbu.s_bwibbu_yield,
s_bwibbu.s_bwibbu_pbr,
s_bwibbu.s_bwibbu_date,
s_cv.s_cv_id,
s_cv.s_cv_cdiv,
s_cv.s_cv_eps1q,
s_cv.s_cv_eps2q,
s_cv.s_cv_eps3q,
s_cv.s_cv_eps4q,
s_cv.s_cv_eps1y,
s_cv.s_cv_eps2y,
s_cv.s_cv_eps3y,
s_cv.s_cv_eps4y,
s_cv.s_cv_roe,
s_cv.s_cv_bvps

FROM `s_day`,`s_bwibbu`,`s_cv`
WHERE s_day.s_day_id=s_cv.s_cv_id
AND s_day.s_day_id=s_bwibbu.s_bwibbu_id

AND s_day.s_day_id=2303
AND s_bwibbu.s_bwibbu_id=2303
AND s_cv.s_cv_id=2303

AND s_day.s_day_date=s_bwibbu.s_bwibbu_date

ORDER BY s_day.s_day_date DESC
LIMIT 1

Showing rows 0 - 0 (1 total, Query took 0.1676 sec)
Showing rows 0 - 0 (1 total, Query took 0.1687 sec)
Showing rows 0 - 0 (1 total, Query took 0.1676 sec)
Showing rows 0 - 0 (1 total, Query took 0.1354 sec)
Showing rows 0 - 0 (1 total, Query took 0.1351 sec)
Showing rows 0 - 0 (1 total, Query took 0.1688 sec)
Showing rows 0 - 0 (1 total, Query took 0.1349 sec)
Showing rows 0 - 0 (1 total, Query took 0.1360 sec)
Showing rows 0 - 0 (1 total, Query took 0.1354 sec)
Showing rows 0 - 0 (1 total, Query took 0.1687 sec)

***********************************************

SELECT
s_day.s_day_id,
s_day.s_day_yesterday,
s_day.s_day_date,
s_bwibbu.s_bwibbu_id,
s_bwibbu.s_bwibbu_name,
s_bwibbu.s_bwibbu_per,
s_bwibbu.s_bwibbu_yield,
s_bwibbu.s_bwibbu_pbr,
s_bwibbu.s_bwibbu_date,
s_cv.s_cv_id,
s_cv.s_cv_cdiv,
s_cv.s_cv_eps1q,
s_cv.s_cv_eps2q,
s_cv.s_cv_eps3q,
s_cv.s_cv_eps4q,
s_cv.s_cv_eps1y,
s_cv.s_cv_eps2y,
s_cv.s_cv_eps3y,
s_cv.s_cv_eps4y,
s_cv.s_cv_roe,
s_cv.s_cv_bvps

FROM `s_day`,`s_bwibbu`,`s_cv`
WHERE s_day.s_day_id=s_cv.s_cv_id
AND s_day.s_day_id=s_bwibbu.s_bwibbu_id

AND s_day.s_day_id=2303
AND s_bwibbu.s_bwibbu_id=2303
AND s_cv.s_cv_id=2303

AND s_day.s_day_date = '100/12/23'
AND s_bwibbu_date = '100/12/23'

Showing rows 0 - 0 (1 total, Query took 0.0500 sec)
Showing rows 0 - 0 (1 total, Query took 0.0501 sec)
Showing rows 0 - 0 (1 total, Query took 0.0517 sec)
Showing rows 0 - 0 (1 total, Query took 0.0509 sec)
Showing rows 0 - 0 (1 total, Query took 0.0503 sec)
Showing rows 0 - 0 (1 total, Query took 0.0170 sec)
Showing rows 0 - 0 (1 total, Query took 0.0844 sec)
Showing rows 0 - 0 (1 total, Query took 0.0847 sec)
Showing rows 0 - 0 (1 total, Query took 0.0508 sec)
Showing rows 0 - 0 (1 total, Query took 0.0507 sec)

2011/12/04

Error: 1010 SQLSTATE: HY000 (ER_DB_DROP_RMDIR)

/

Error: 1010 SQLSTATE: HY000 (ER_DB_DROP_RMDIR)
Message: Error dropping database (can't rmdir '%s', errno: %d)

//
C:\AppServ\MySQL\data\

2011/11/25

TIMESTAMP Properties

Ref>
http://dev.mysql.com/doc/refman/5.1/en/timestamp.html

//

UPDATE 'table_name'
SET 'column_name'=current_time
WHERE 'column_name'=0000-00-00 00:00:00

import CSV

//phpMyAdmin - 2.10.3

>Import
>CSV

//default

Fields terminated by ;
Fields enclosed by "
Fields escaped by \
Lines terminated by auto
Column names


//
"49956";"";"";"";"";"";"";"";"2011-11-22";"31.35";"32.00";"30.05";"30.05";"1635000";"30.05";"";"";"";"";"";""
"4956";"";"";"";"";"";"";"";"2011-11-21";"34.60";"34.60";"32.30";"32.30";"1488000";"32.30";"";"";"";"";"";""

//
1234;;;;;;;;2011-11-23;32.55;32.70;31.70;31.75;11375000;31.75;;;;;;
2234;;;;;;;;2011-11-23;32.55;32.70;31.70;31.75;11375000;31.75;;;;;;
3234;;;;;;;;2011-11-23;32.55;32.70;31.70;31.75;11375000;31.75;;;;;;
4234;;;;;;;;2011-11-23;32.55;32.70;31.70;31.75;11375000;31.75;;;;;;