No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, wi
Trang 2Oracle SQL
Jumpstart with Examples
Powell_title.fm Page 1 Friday, July 30, 2004 10:10 AM
Trang 3This page intentionally left blank
Trang 4Oracle SQL
Jumpstart with Examples
Gavin Powell Carol McCullough-Dieter
AMSTERDAM • BOSTON • HEIDELBERG • LONDON NEW YORK • OXFORD • PARIS • SAN DIEGO• SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO
Powell_title.fm Page 3 Friday, July 30, 2004 10:10 AM
Trang 5Elsevier Digital Press
200 Wheeler Road, Burlington, MA 01803, USA Linacre House, Jordan Hill, Oxford OX2 8DP, UK Copyright © 2005, Elsevier Inc All rights reserved
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher Permissions may be sought directly from Elsevier’s Science & Technology Rights Department in Oxford, UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, e-mail: permissions@elsevier.com.uk You may also complete your request on-line via the Elsevier homepage (http://elsevier.com), by selecting “Customer Support” and then “Obtaining Permissions.”
Recognizing the importance of preserving what has been written, Elsevier prints its books on acid-free paper whenever possible
Library of Congress Cataloging-in-Publication Data
Application submitted
ISBN: 1-55558-323-7
British Library Cataloguing-in-Publication Data
A catalogue record for this book is available from the British Library
For information on all Digital Press publications visit our Web site at www.digitalpress.com and www.bh.com/digitalpress
04 05 06 07 08 09 10 9 8 7 6 5 4 3 2 1 Printed in the United States of America
Powell_title.fm Page 4 Friday, July 30, 2004 10:10 AM
Trang 6Index 651
Index
defined, 315
results, 333
subqueries, 283
syntax, 330
WHERE clause, 332
UPDATEXML function, 379–80
defined, 379
illustrated, 380
subtree deletion, 381
use guidelines, 379
Updating rows, 330–34
multiple, 331–34
multiple columns, 332
one, 331
with subqueries, 331
UPPER function, 180
User-defined datatypes, 347–48
User-defined functions
defined, 176
GETTIME, 256, 257
User-defined operators, 131
creating, 131
defined, 124
USERENV function, 195–96
USER function, 195
USER_OBJECTs metadata view, 445
Users, 503–11
authentication methods, 506
creating, 505–8
dropping, 510–11
feature-related, 505
granting roles to, 525–26
Oracle-provided, 504–5
passwords, modifying, 508–10
revoking roles from, 526–27
roles, 56
SYS, 504–5
SYSTEM, 505
USING clause, 213–15
defined, 213
illustrated use, 215
VARCHAR2 data type, 55, 340 Variables, 148–51
iSQL*Plus, 171 names, 148 substitution, 148, 150 values, prompt for, 150 VARIANCE function, 238 VAR_POP function, 239 VARRAY collections, 349–50 VAR_SAMP function, 239 Views, 425–45
changing, 433–35 with columns, 439–40 complex, 427, 430–33 constraint, 427, 429–30 data dictionary, 442–45 defined, 425–26 DML commands and, 437–41 dropping, 433–35
functions in, 432 grouping in, 432 inline, 106, 281–82, 432–33 inserting data with, 439 with joins, 430–32, 440–41 materialized, 426
metadata, 354–55, 380–81, 421–23, 441,
469, 487–88, 501, 530, 568 querying, 429, 435–37
reasons for creating, 426 simple, 426–27, 428–29 subqueries, 434
updateable, 437 working with, 435–41 VSIZE function, 196
WHERE clause, 18, 97–105 bitmap indexes and, 484 defined, 97–98
evaluation, 107 examples, 98–101
Trang 7652 Index
expression conditions, 101–5
expression orders, 108
for filtering rows, 253
functions, 176
illustrated, 98
logical operators in, 105
matching, to indexes, 484
matching conditions, 99
multiple-column subquery, 278
requirements to data comparison, 100
restricting by date, 98
syntax, 97–101
WHILE loop, 560, 563–64
defined, 560
example, 563–64
execution, 563
statement syntax, 563
XML, 357–81
conditions, 47, 132
content, changing/removing, 378–80
database and, 373–80
documents, creating, 361–73
documents, in Web browser, 359
documents, new, 373–74
documents, retrieving, 374–78
documents, returning data from, 48
documents, storage, 378
element tags, 364
element tags with tag attributes, 365
functional capability enhancements, 47
functions, 47–48
generating, from Oracle SQL code, 48
generating, from tables, 362–73
generation format, 368
improvements in Oracle Database 10g, 45
object hierarchical nature, 370
using, in Oracle, 360–80
XMLAGG function, 363, 365, 371, 372
XMLATTRIBUTES function, 363
XMLCOLATTVAL function, 363, 366, 367 XML datatype, 355
XMLELEMENT function, 363 XMLFOREST function, 363, 366, 367 XMLSEQUENCE function, 363 XMLTRANSFORM function, 363 XMLType datatype, 361–62 defined, 361
example, 361–62 output, 375
See also Datatypes
XMLType tables, 384