Data Definition Guide © 2020 Embarcadero Technologies, Inc
Total Page:16
File Type:pdf, Size:1020Kb
Product Documentation InterBase 2020 Update 1 Data Definition Guide © 2020 Embarcadero Technologies, Inc. Embarcadero, the Embarcadero Technologies logos, and all other Embarcadero Technologies product or service names are trademarks or registered trademarks of Embar- cadero Technologies, Inc. All other trademarks are property of their respective owners. Embarcadero Technologies, Inc. is a leading provider of award-winning tools for application developers. Embarcadero enables developers to design systems right, build them faster and run them better, regard- less of their platform or programming language. Ninety of the Fortune 100 and an active community of more than three million users worldwide rely on Embarcadero products to increase productivity, reduce costs and accelerate innovation. The company's flagship tools include: Embarcadero® RAD Studio™, Del- phi®, C++Builder®, JBuilder®, and the IoT Award winning InterBase®. Founded in 1993, Embarcadero is headquartered in Austin, with offices located around the world. Embarcadero is online at www.embar- cadero.com. May, 2020 Table of Contents 2.4. Creating Read-only Databases ............. 23 TABLE OF CONTENTS 3. Altering a Database ................................... 23 4. Dropping a Database ................................ 24 5. Creating a Database Shadow ................... 25 DATA DEFINITION GUIDE .............................. 1 5.1. Advantages of Creating a Database Shadow ......................................................... 25 USING THE DATA DEFINITION GUIDE ......... 2 5.2. Limitations of Creating a Database Shadow ......................................................... 25 1. What is Data Definition? ............................. 2 5.3. Before Creating a Shadow ................... 25 2. Who Should Use the Data Definition 5.4. Using CREATE SHADOW ...................... 26 Guide .................................................................. 3 6. Dropping a Shadow .................................. 29 3. Using isql ...................................................... 3 7. Expanding the Size of a Shadow .............. 29 4. Using a Data Definition File ........................ 3 8. Using isql to Extract Data Definitions ...... 30 DESIGNING DATABASES ................................ 4 WORKING WITH TABLESPACES .................. 31 1. Overview of Design Issues .......................... 4 1. Usage ........................................................... 31 1.1. Database Versus Data Model .................. 4 2. ISQL Support .............................................. 33 1.2. Design Goals ............................................ 5 3. Requirements and Constraints ................. 33 2. Design Framework ....................................... 5 4. Backup, Restore and Recovery ................. 34 3. Analyzing Requirements ............................. 6 4.1. User interface/Usability ......................... 34 4. Collecting and Analyzing Data ................... 6 4.2. Services API ........................................... 37 5. Identifying Entities and Attributes ............. 6 6. Designing Tables .......................................... 8 SPECIFYING DATA TYPES ............................ 38 7. Determining Unique Attributes .................. 9 8. Developing a Set of Rules .......................... 9 1. About InterBase Data Types ..................... 38 8.1. Specifying a Data Type ............................ 9 2. Where to Specify Data Types ................... 40 8.2. Choosing International Character 3. Defining Numeric Data Types .................. 41 Sets ................................................................ 10 3.1. Integer Data Types ................................. 41 8.3. Specifying Domains ............................... 10 3.2. Fixed-decimal Data Types ..................... 41 8.4. Setting Default Values and NULL Sta- 3.3. Floating-point Data Types .................... 46 tus .................................................................. 10 4. Date and Time Data Types ....................... 47 8.5. Defining Integrity Constraints ................ 11 4.1. Converting to the DATE, TIME, and 8.6. Defining CHECK Constraints .................. 11 TIMESTAMP Data Types .............................. 47 9. Establishing Relationships between Ob- 4.2. How InterBase Stores Date Values ....... 48 jects .................................................................. 11 5. Character Data Types ................................ 48 9.1. Enforcing Referential Integrity ............... 12 5.1. Specifying a Character Set .................... 49 9.2. Normalizing the Database .................... 13 5.2. Fixed-length Character Data ................ 50 9.3. Choosing Indexes .................................. 16 5.3. Variable-length Character Data ............ 51 9.4. Increasing Cache Size ........................... 16 6. The BOOLEAN Data Type ......................... 52 9.5. Creating a Multifile, Distributed 7. Defining BLOB Data Types ........................ 53 Database ....................................................... 17 7.1. BLOB Columns ....................................... 53 10. Planning Security ..................................... 17 7.2. BLOB Segment Length ......................... 54 11. Naming Objects ....................................... 17 7.3. BLOB Subtypes ...................................... 55 7.4. BLOB Filters ........................................... 55 CREATING DATABASES ............................... 18 7.5. Using BLOBs with VARCHAR Data ....... 56 8. Defining Arrays .......................................... 57 1. What You Should Know ............................ 18 8.1. Multi-dimensional Arrays ...................... 58 2. Creating a Database .................................. 18 8.2. Specifying Subscript Ranges for Array 2.1. Database File Naming Conventions ...... 18 Dimensions ................................................... 58 2.2. Creating a Database Using a Data Defi- 9. Converting Data Types .............................. 59 nition File ....................................................... 19 9.1. Implicit Type Conversions ..................... 59 2.3. Using CREATE DATABASE ..................... 19 9.2. Explicit Type Conversions ..................... 60 iii Table of Contents 2. Advantages of Views ............................... 100 WORKING WITH DOMAINS ........................ 62 3. Creating Views ......................................... 100 3.1. Specifying View Column Names .......... 101 1. Creating Domains ...................................... 62 3.2. Using the SELECT Statement ............... 101 1.1. Specifying the Domain Data Type ......... 62 3.3. Using Expressions to Define 1.2. Specifying Domain Defaults .................. 63 Columns ....................................................... 101 1.3. Specifying NOT NULL ............................ 64 3.4. Types of Views: Read-only and Up- 1.4. Specifying Domain CHECK Con- date-able ..................................................... 102 straints ........................................................... 64 3.5. Inserting Data through a View ............ 103 1.5. Using the VALUE Keyword .................... 65 4. Dropping Views ....................................... 104 1.6. Specifying Domain Collation Order ...... 66 2. Altering Domains ....................................... 66 WORKING WITH CHANGE VIEWS ............ 105 3. Dropping a Domain ................................... 67 1. Getting Started with Change Views ....... 105 WORKING WITH TABLES ............................. 68 2. Creating Subscriptions to Change Views .............................................................. 106 1. Before Creating a Table ............................ 68 2.1. DROP SUBSCRIPTION .......................... 107 2. Creating Tables .......................................... 68 2.2. Grant Subscribe ................................... 108 2.1. Defining Columns .................................. 68 2.3. Set Subscription ................................... 108 2.2. Defining Integrity Constraints on a Ta- 3. Statement Execution ............................... 109 ble ................................................................. 73 4. Change Views API Support ..................... 109 2.3. Defining a CHECK Constraint ............... 77 5. Change Views SQL Language Sup- 2.4. Using the EXTERNAL FILE Option ........ 79 port ................................................................. 110 3. Altering Tables ........................................... 82 3.1. Before using ALTER TABLE ................... 83 WORKING WITH STORED PROCE- 3.2. Using ALTER TABLE .............................. 84 DURES .......................................................... 113 4. Dropping Tables ........................................ 89 4.1. Dropping a Table .................................. 89 1. Overview of Stored Procedures ............. 113 4.2. DROP TABLE Syntax ............................. 89 2. Working with Procedures ....................... 113 5. Global Temporary Tables .......................... 89 2.1. Working with Procedures Using a Data 5.1. Creating a Global Temporary Table ..... 90 Definition File ............................................... 114 5.2. Altering a Global Temporary Table ...... 90 2.2. Calling Stored Procedures ................... 114 5.3. Requirements and Constraints .............. 91 2.3. Privileges for Stored Procedures ......... 115 3. Creating Procedures ................................ 115 WORKING WITH INDEXES ..........................