Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain...
Transcript of Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain...
![Page 1: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/1.jpg)
Copyright © 2004, Oracle. All rights reserved.
Managing Schema Objects
![Page 2: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/2.jpg)
Copyright © 2004, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to do the following:• Create and modify tables• Define constraints• View the attributes of a table• View the contents of a table• Create indexes and views
![Page 3: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/3.jpg)
Copyright © 2004, Oracle. All rights reserved.
What Is a Schema?
HR schemaHR user
owns
![Page 4: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/4.jpg)
Copyright © 2004, Oracle. All rights reserved.
Schemas
Schemas created as part of the database creation process:• SYS• SYSTEM• Sample schemas
![Page 5: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/5.jpg)
Copyright © 2004, Oracle. All rights reserved.
Accessing Schema Objects
Click a link to access the schema objects.
![Page 6: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/6.jpg)
Copyright © 2004, Oracle. All rights reserved.
Naming Database Objects
• Names must be from 1 to 30 bytes long with these exceptions:– Names of databases are limited to 8 bytes– Names of database links can be as long as 128
bytes• Nonquoted names cannot be Oracle reserved
words.• Nonquoted names must begin with an alphabetic
character from your database character set.
![Page 7: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/7.jpg)
Copyright © 2004, Oracle. All rights reserved.
Naming Database Objects
• Nonquoted names can contain only – Alphanumeric characters from your database
character set– The underscore (_)– Dollar sign ($)– Pound sign (#)
• No two objects can have the same name within the same namespace
![Page 8: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/8.jpg)
Copyright © 2004, Oracle. All rights reserved.
Schema Object Namespaces
The following have their own namespace:• Indexes• Constraints• Clusters• Database triggers• Private database
links• Dimensions
The following are in the same namespace:• Tables• Views• Sequences• Private synonyms• Stand-alone
procedures• Stand-alone stored
functions• Packages• Materialized views• User-defined types
![Page 9: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/9.jpg)
Copyright © 2004, Oracle. All rights reserved.
Specifying Data Types in Tables
Common data types:• CHAR(size): Fixed-length character data of length
size bytes• VARCHAR2(size): Variable-length character string
having maximum length size bytes• DATE: Valid date range from January 1, 4712 BC to
December 31, 9999 AD• NUMBER(p,s): Number having precision p and
scale s
![Page 10: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/10.jpg)
Copyright © 2004, Oracle. All rights reserved.
Other Data Types
• FLOAT• INTEGER• NCHAR• NVARCHAR2• LONG• LONG RAW• RAW
• ROWID• UROWID• BLOB• CLOB• NCLOB• BFILE• TIMESTAMP
![Page 11: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/11.jpg)
Copyright © 2004, Oracle. All rights reserved.
Creating and Modifying Tables
Specify the table name and schema.
Specify the column names, data types, and lengths.
![Page 12: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/12.jpg)
Copyright © 2004, Oracle. All rights reserved.
Understanding Data Integrity
![Page 13: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/13.jpg)
Copyright © 2004, Oracle. All rights reserved.
Defining Constraints
![Page 14: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/14.jpg)
Copyright © 2004, Oracle. All rights reserved.
Viewing the Attributes of a Table
![Page 15: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/15.jpg)
Copyright © 2004, Oracle. All rights reserved.
Viewing the Contents of a Table
![Page 16: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/16.jpg)
Copyright © 2004, Oracle. All rights reserved.
Actions with Tables
![Page 17: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/17.jpg)
Copyright © 2004, Oracle. All rights reserved.
Creating Indexes
![Page 18: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/18.jpg)
Copyright © 2004, Oracle. All rights reserved.
What Is a View?
• Tailored representation of data in a table or view• Views do not contain data
![Page 19: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/19.jpg)
Copyright © 2004, Oracle. All rights reserved.
Creating Views
![Page 20: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/20.jpg)
Copyright © 2004, Oracle. All rights reserved.
What Is a Sequence?
![Page 21: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/21.jpg)
Copyright © 2004, Oracle. All rights reserved.
Using a Sequence
![Page 22: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/22.jpg)
Copyright © 2004, Oracle. All rights reserved.
Summary
In this lesson, you should have learned how to:• Create and modify tables• Define constraints• View the attributes of a table• View the contents of a table• Create indexes and views
![Page 23: Managing Schema Objects - WordPress.com · Naming Database Objects • Nonquoted names can contain only – Alphanumeric characters from your database character set – The underscore](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f311e0770f5a14eb64c2f20/html5/thumbnails/23.jpg)
Copyright © 2004, Oracle. All rights reserved.
Practice 8: Working with Tables
This practice covers the following:• Creating tables and indexes• Modifying tables• Dropping a table• Creating a view