Serveur d'impression

CREER LA TABLE – Bien choisir son serveur d impression

Le 6 octobre 2019 - 85 minutes de lecture

Objectif

Nouse le CRÉER TABLE instruction pour créer l’un des types de tables suivants:

  • UNE table relationnelle, qui est la structure de base pour stocker les données utilisateur.

  • Un table objet, qui est une table qui utilise un type d’objet pour une définition de colonne. Une table d'objets est explicitement définie pour contenir des instances d'objet d'un type particulier.

Vous pouvez également créer un type d'objet, puis l'utiliser dans une colonne lors de la création d'une table relationnelle.

Les tables sont créées sans données sauf si une sous-requête est spécifiée. Vous pouvez ajouter des lignes à une table avec le INSÉRER déclaration. Après avoir créé une table, vous pouvez définir des colonnes, des partitions et des contraintes d’intégrité supplémentaires avec AJOUTER clause de la MODIFIER TABLE déclaration. Vous pouvez modifier la définition d’une colonne ou d’une partition existante avec MODIFIER clause de la MODIFIER TABLE déclaration.

Sujets supplémentaires

Conditions préalables

Pour créer une table relationnelle dans votre propre schéma, vous devez disposer du CRÉER TABLE privilège système. Pour créer une table dans le schéma d’un autre utilisateur, vous devez disposer du CRÉER TOUT TABLE privilège système. De plus, le propriétaire du schéma devant contenir la table doit avoir un quota d’espace sur l’espace de table pour contenir la table ou le ILLIMITÉ TABLESPACE privilège système.

Outre ces privilèges de table, pour créer une table objet ou une table relationnelle avec une colonne de type objet, le propriétaire de la table doit disposer du EXÉCUTER privilège d'objet afin d'accéder à tous les types référencés par la table, ou vous devez disposer du EXÉCUTER TOUT TYPE privilège système. Ces privilèges doivent être accordés explicitement et non acquis via un rôle.

De plus, si le propriétaire de la table a l'intention d'accorder l'accès à la table à d'autres utilisateurs, il doit alors avoir obtenu l'autorisation EXÉCUTER privilège d'objet sur les types référencés AVEC SUBVENTION OPTION, ou avoir le EXÉCUTER TOUT TYPE privilège système AVEC ADMIN OPTION. Sans ces privilèges, le propriétaire de la table ne dispose pas de privilèges suffisants pour accorder l'accès à la table à d'autres utilisateurs.

Pour activer une contrainte de clé unique ou primaire, vous devez disposer des privilèges nécessaires pour créer un index sur la table. Vous avez besoin de ces privilèges, car Oracle Database crée un index sur les colonnes de la clé unique ou primaire du schéma contenant la table.

Pour créer une table externe, vous devez disposer des privilèges de système d'exploitation requis en lecture et en écriture sur les répertoires appropriés du système d'exploitation. Vous devez avoir le LIS privilège object sur l'objet de répertoire de base de données correspondant au répertoire du système d'exploitation dans lequel résident les données externes. Vous devez aussi avoir le ÉCRIRE Privilège d’objet sur le répertoire de la base de données dans lequel les fichiers résideront si vous spécifiez un fichier journal ou un fichier incorrect dans le répertoire. opaque_format_spec ou si vous déchargez des données dans une table externe à partir d'une table de base de données en spécifiant le COMME sous-requête clause.

Syntaxe

create_table:: =

La description de create_table.gif suit

Description de l'illustration create_table.gif

(table_relationnelle:: =, objet_table :: =, XMLType_table :: =)

table_relationnelle:: =

La description de relational_table.gif suit

Description de l'illustration relational_table.gif

Remarque:

Chacune des clauses qui suivent le nom de la table est facultative pour toute table relationnelle donnée. Cependant, pour chaque table, vous devez au moins spécifier les noms de colonne et les types de données à l'aide de la commande propriétés_relationnelles clause ou un COMME sous-requête clause utilisant la propriétés_table clause.

(propriétés_relationnelles:: =, propriétés physiques:: =, propriétés_table:: =)

objet_table :: =

La description de object_table.gif suit

Description de l'illustration object_table.gif

(object_table_substitution :: =, propriétés_objet:: =, oid_clause:: =, oid_index_clause:: =, propriétés physiques:: =, propriétés_table:: =)

XMLType_table :: =

La description de XMLType_table.gif suit

Description de l'illustration XMLType_table.gif

(XMLType_storage:: =, XMLSchema_spec:: =, oid_clause:: =, oid_index_clause:: =, propriétés physiques:: =, propriétés_table:: =)

propriétés_relationnelles:: =

La description de relationnel_properties.gif suit

Description de l'illustration relational_properties.gif

(définition_colonne:: =, contrainte:: =, supplemental_logging_props :: =)

définition_colonne:: =

Description de column_definition.gif ci-dessous

Description de l'illustration column_definition.gif

(encryption_spec:: =, contrainte:: =)

encryption_spec:: =

La description de encryption_spec.gif suit

Description de l'illustration encryption_spec.gif

object_table_substitution :: =

La description de object_table_substitution.gif suit

Description de l'illustration object_table_substitution.gif

propriétés_objet:: =

La description de object_properties.gif suit

Description de l'illustration object_properties.gif

(contrainte:: =, supplemental_logging_props :: =)

oid_clause:: =

La description de oid_clause.gif suit

Description de l'illustration oid_clause.gif

oid_index_clause:: =

La description de oid_index_clause.gif suit

Description de l'illustration oid_index_clause.gif

(clause_attributs_ physiques:: =)

propriétés physiques:: =

La description de physical_properties.gif suit

Description de l'illustration physical_properties.gif

(segment_attributes_clause :: =, compression_table:: =, index_org_table_clause :: =, clause_table_externe :: =)

segment_attributes_clause :: =

La description de segment_attributes_clause.gif suit

Description de l'illustration segment_attributes_clause.gif

(clause_attributs_ physiques:: =, clause_logging:: =)

clause_attributs_ physiques:: =

La description de physical_attributes_clause.gif est la suivante

Description de l'illustration physical_attributes_clause.gif

(clause_stockage:: =)

compression_table:: =

La description de table_compression.gif suit

Description de l'illustration table_compression.gif

propriétés_table:: =

La description de table_properties.gif suit

Description de l'illustration table_properties.gif

(propriétés de la colonne:: =, clauses_partitionnement_table :: =, clause_parallèle :: =, enable_disable_clause :: =, row_movement_clause :: =, sous-requête:: =)

propriétés de la colonne:: =

La description de column_properties.gif suit

Description de l'illustration column_properties.gif

(object_type_col_properties:: =, nested_table_col_properties :: =, varray_col_properties :: =, LOB_storage_clause:: =, LOB_partition_storage:: =, XMLType_column_properties :: =)

object_type_col_properties:: =

La description de object_type_col_properties.gif suit

Description de l'illustration object_type_col_properties.gif

substitutable_column_clause:: =

Description de substitutable_column_clause.gif ci-dessous

Description de l'illustration substitutable_column_clause.gif

nested_table_col_properties :: =

La description de nested_table_col_properties.gif est la suivante

Description de l'illustration nested_table_col_properties.gif

(substitutable_column_clause:: =, propriétés_objet:: =, propriétés physiques:: =, propriétés de la colonne:: =)

varray_col_properties :: =

La description de varray_col_properties.gif suit

Description de l'illustration varray_col_properties.gif

(substitutable_column_clause:: =, LOB_parameters :: =)

LOB_storage_clause:: =

La description de LOB_storage_clause.gif suit

Description de l'illustration LOB_storage_clause.gif

(LOB_parameters :: =)

LOB_parameters :: =

La description de LOB_parameters.gif suit

Description de l'illustration LOB_parameters.gif

(clause_stockage:: =)

clause_logging:: =

La description de logging_clause.gif suit

Description de l'illustration logging_clause.gif

LOB_partition_storage:: =

La description de LOB_partition_storage.gif suit

Description de l'illustration LOB_partition_storage.gif

(LOB_storage_clause:: =, varray_col_properties :: =)

XMLType_column_properties :: =

La description de XMLType_column_properties.gif suit

Description de l'illustration XMLType_column_properties.gif

(XMLType_storage:: =, XMLSchema_spec:: =)

XMLType_storage:: =

Description de XMLType_storage.gif ci-dessous

Description de l'illustration XMLType_storage.gif

(LOB_parameters :: =)

XMLSchema_spec:: =

La description de XMLSchema_spec.gif suit

Description de l'illustration XMLSchema_spec.gif

row_movement_clause :: =

La description de row_movement_clause.gif suit

Description de l'illustration row_movement_clause.gif

index_org_table_clause :: =

La description de index_org_table_clause.gif suit

Description de l'illustration index_org_table_clause.gif

(mapping_table_clauses:: =, key_compression :: =, index_org_overflow_clause :: =)

mapping_table_clauses:: =

La description de mapping_table_clauses.gif suit

Description de l'illustration mapping_table_clauses.gif

key_compression :: =

La description de key_compression.gif suit

Description de l'illustration key_compression.gif

index_org_overflow_clause :: =

La description de index_org_overflow_clause.gif suit

Description de l'illustration index_org_overflow_clause.gif

(segment_attributes_clause :: =)

supplemental_logging_props :: =

La description de supplemental_logging_props.gif suit

Description de l'illustration supplemental_logging_props.gif

supplemental_log_grp_clause:: =

La description de supplemental_log_grp_clause.gif est la suivante

Description de l'illustration supplemental_log_grp_clause.gif

supplemental_id_key_clause:: =

La description de supplemental_id_key_clause.gif est la suivante

Description de l'illustration supplemental_id_key_clause.gif

clause_table_externe :: =

La description de external_table_clause.gif suit

Description de l'illustration external_table_clause.gif

(données_externes:: =)

données_externes:: =

La description de external_data_properties.gif suit

Description de l'illustration external_data_properties.gif

(opaque_format_spec: Voir Utilitaires de base de données Oracle pour savoir comment spécifier des valeurs pour opaque_format_spec.)

clauses_partitionnement_table :: =

La description de table_partitioning_clauses.gif suit

Description de l'illustration table_partitioning_clauses.gif

(range_partitioning:: =, hash_partitioning :: =, partition_partition :: =, partitionnement composite :: =)

range_partitioning:: =

La description de range_partitioning.gif suit

Description de l'illustration range_partitioning.gif

(plage_valeurs_clause:: =, description_partition_table:: =)

hash_partitioning :: =

La description de hash_partitioning.gif suit

Description de l'illustration hash_partitioning.gif

(individual_hash_partitions:: =, hash_partitions_by_quantity:: =)

partition_partition :: =

La description de list_partitioning.gif suit

Description de l'illustration list_partitioning.gif

(list_values_clause:: =, description_partition_table:: =)

partitionnement composite :: =

La description de composite_partitioning.gif suit

Description de l'illustration composite_partitioning.gif

(subpartition_by_list:: =, subpartition_by_hash:: =, plage_valeurs_clause:: =, description_partition_table:: =)

subpartition_by_hash:: =

La description de subpartition_by_hash.gif suit

Description de l'illustration subpartition_by_hash.gif

(subpartition_template:: =)

individual_hash_partitions:: =

La description de individual_hash_partitions.gif suit

Description de l'illustration individual_hash_partitions.gif

(partitioning_storage_clause:: =)

hash_partitions_by_quantity:: =

Description de hash_partitions_by_quantity.gif ci-dessous

Description de l'illustration hash_partitions_by_quantity.gif

subpartition_by_list:: =

La description de subpartition_by_list.gif suit

Description de l'illustration subpartition_by_list.gif

(subpartition_template:: =)

subpartition_template:: =

La description de subpartition_template.gif suit

Description de l'illustration subpartition_template.gif

(list_values_clause:: =, partitioning_storage_clause:: =)

plage_valeurs_clause:: =

La description de range_values_clause.gif suit

Description de l'illustration range_values_clause.gif

list_values_clause:: =

La description de list_values_clause.gif suit

Description de l'illustration list_values_clause.gif

description_partition_table:: =

La description de table_partition_description.gif suit

Description de l'illustration table_partition_description.gif

(segment_attributes_clause :: =, compression_table:: =, LOB_storage_clause:: =, varray_col_properties :: =, partition_level_subpartition:: =)

partition_level_subpartition:: =

La description de partition_level_subpartition.gif suit

Description de l'illustration partition_level_subpartition.gif

(subpartition_spec:: =)

subpartition_spec:: =

La description de subpartition_spec.gif suit

Description de l'illustration subpartition_spec.gif

(list_values_clause:: =, partitioning_storage_clause:: =)

partitioning_storage_clause:: =

La description de partitioning_storage_clause.gif suit

Description de l'illustration partitioning_storage_clause.gif

clause_parallèle :: =

La description de parallel_clause.gif suit

Description de l'illustration parallel_clause.gif

enable_disable_clause :: =

La description de enable_disable_clause.gif est la suivante

Description de l'illustration enable_disable_clause.gif

(using_index_clause :: =, exceptions_clause n'est pas supporté dans CRÉER TABLE déclarations)

using_index_clause :: =

Description de using_index_clause.gif ci-dessous

Description de l'illustration using_index_clause.gif

(create_index:: =, propriété_index:: =)

propriété_index:: =

La description de index_properties.gif suit

Description de l'illustration index_properties.gif

(global_partitioned_index :: =, local_partitioned_index :: =–partie de CRÉER INDICE, index_attributes:: =, domain_index_clause: non pris en charge dans using_index_clause)

index_attributes:: =

Description de index_attributes.gif ci-dessous

Description de l'illustration index_attributes.gif

(clause_attributs_ physiques:: =, logging_clause:: =, key_compression :: =, clause_parallèle: non pris en charge dans using_index_clause)

Sémantique

table_relationnelle

GLOBAL TEMPORARY

Spécifier GLOBAL TEMPORAIRE pour indiquer que la table est temporaire et que sa définition est visible pour toutes les sessions avec les privilèges appropriés. le Les données dans une table temporaire est visible uniquement pour la session qui insère les données dans la table.

Lorsque vous créez une table temporaire pour la première fois, ses métadonnées de table sont stockées dans le dictionnaire de données, mais aucun espace n'est alloué pour les données de la table. Un espace est alloué pour le segment de table au moment de la première opération DML sur la table. La définition de la table temporaire persiste de la même manière que les définitions des tables normales, mais le segment de la table et toutes les données contenues dans la table sont soit spécifique à la session ou spécifique à la transaction Les données. Vous spécifiez si le segment de table et les données sont spécifiques à la session ou à la transaction avec les mots-clés ON COMMIT.

Vous pouvez effectuer des opérations DDL (telles que MODIFIER TABLE, LAISSEZ TOMBER TABLE, CRÉER INDICE) sur une table temporaire uniquement lorsqu'aucune session n'est liée à celle-ci. Une session devient liée à une table temporaire en effectuant une opération INSÉRER opération sur la table. Une session devient non liée à la table temporaire en émettant un TRONQUER ou à la fin de la session, ou, pour une table temporaire spécifique à une transaction, en émettant un COMMETTRE ou RETOUR EN ARRIERE déclaration.

Restrictions sur les tables temporaires Les tables temporaires sont soumises aux restrictions suivantes:

  • Les tables temporaires ne peuvent pas être partitionnées, en cluster ou organisées par index.

  • Vous ne pouvez spécifier aucune contrainte de clé étrangère sur les tables temporaires.

  • Les tables temporaires ne peuvent pas contenir de colonnes de table imbriquée.

  • Vous ne pouvez pas spécifier les clauses suivantes du LOB_storage_clause: TABLESPACE, clause_stockage, ou clause_logging.

  • Les requêtes DML parallèles et parallèles ne sont pas prises en charge pour les tables temporaires. Les indications parallèles sont ignorées. Spécification de la clause_parallèle renvoie une erreur.

  • Vous ne pouvez pas spécifier le segment_attributes_clause, nested_table_col_properties, ou clause_parallèle.

  • Les transactions distribuées ne sont pas prises en charge pour les tables temporaires.

schéma

Spécifiez le schéma pour contenir la table. Si vous omettez schéma, la base de données crée alors la table dans votre propre schéma.

table

Spécifiez le nom de la table ou de la table d'objets à créer.

propriétés_relationnelles

Les propriétés relationnelles décrivent les composants d'une table relationnelle.

définition_colonne

le définition_colonne vous permet de définir les caractéristiques de la colonne.

colonne

Spécifiez le nom d'une colonne de la table.

Si vous spécifiez également COMME sous-requêtealors vous pouvez omettre colonne et Type de données sauf si vous créez une table organisée par index. Si vous spécifiez COMME sous-requête lors de la création d'une table organisée par index, vous devez spécifier colonneet vous devez l'omettre Type de données.

Le nombre maximum absolu de colonnes dans une table est 1000. Toutefois, lorsque vous créez une table objet ou une table relationnelle avec des colonnes d'objet, une table imbriquée, un tableau de variables ou REF type, Oracle Database mappe les colonnes des types définis par l'utilisateur sur des colonnes relationnelles, créant ainsi des colonnes masquées qui comptent pour la limite de 1 000 colonnes.

Type de données

Spécifiez le type de données d'une colonne.

Notes sur les types de données de colonne de table Les remarques suivantes s'appliquent aux types de données des colonnes de table:

  • Si vous spécifiez COMME sous-requêtealors vous pouvez omettre Type de données. Si vous créez une table organisée par index et que vous spécifiez COMME sous-requête, vous devez alors omettre le type de données.

  • Vous pouvez aussi omettre Type de données si l'instruction désigne la colonne en tant que partie d'une clé étrangère dans une contrainte d'intégrité référentielle. Oracle Database affecte automatiquement à la colonne le type de données de la colonne correspondante de la clé référencée de la contrainte d'intégrité référentielle.

  • Ne créez pas de table avec LONGUE Colonnes. Utiliser les colonnes LOB (CLOB, NCLOB, GOUTTE) au lieu. LONGUE les colonnes sont prises en charge uniquement pour des raisons de compatibilité ascendante.

Restriction sur les types de données de colonne de table Vous pouvez spécifier une colonne de type ROWID, mais Oracle Database ne garantit pas que les valeurs de ces colonnes sont des ID de ligne valides.

Voir également:

"Types de données" pour plus d'informations sur LONGUE colonnes et sur les types de données fournis par Oracle

TRIER

le TRIER mot-clé est valide uniquement si vous créez cette table dans le cadre d'un cluster de hachage et uniquement pour les colonnes qui sont également des colonnes de cluster.

Cette clause indique à la base de données de trier les lignes du cluster sur cette colonne avant d'appliquer la fonction de hachage. Cela pourrait améliorer le temps de réponse lors d'opérations ultérieures sur les données en cluster.

DÉFAUT

le DÉFAUT Cette clause vous permet de spécifier une valeur à affecter à la colonne si une nouvelle INSÉRER instruction omet une valeur pour la colonne. Le type de données de l'expression doit correspondre à celui de la colonne. La colonne doit également être suffisamment longue pour contenir cette expression.

le DÉFAUT expression peut inclure n'importe quelle fonction SQL tant qu'elle ne renvoie pas d'argument littéral, de référence de colonne ou d'appel de fonction imbriquée.

Restriction sur les valeurs de colonne par défaut UNE DÉFAUT expression ne peut pas contenir de références à des fonctions PL / SQL ni à d’autres colonnes, les pseudocolonnes CURRVAL, NEXTVAL, NIVEAU, AVANT, et ROWNUM, ou des constantes de date qui ne sont pas complètement spécifiées.

CRYPTER encryption_spec

le CRYPTER Cette clause vous permet d’utiliser la fonctionnalité de chiffrement de données transparente pour chiffrer la colonne que vous définissez. Vous pouvez chiffrer des colonnes de type CARBONISER, NCHAR, VARCHAR2, NVARCHAR2, NOMBRE, DATE, et BRUT. Les données n'apparaissent pas sous leur forme chiffrée pour les utilisateurs autorisés, tels que l'utilisateur qui chiffre la colonne.

EN UTILISANT 'algorithme d'encodage' Utilisez cette clause pour spécifier le nom de l'algorithme à utiliser. Les algorithmes valides sont 3DES168, AES128, AES192, et AES256. Si vous omettez cette clause, la base de données utilise AES192. Si vous chiffrez plusieurs colonnes dans la même table et si vous spécifiez la EN UTILISANT clause pour l’une des colonnes, vous devez spécifier le même algorithme de chiffrement pour toutes les colonnes chiffrées.

IDENTIFIÉ PAR mot de passe Si vous spécifiez cette clause, la base de données dérive la clé de colonne du mot de passe spécifié.

SEL | PAS DE SEL Par défaut, la base de données ajoute une chaîne aléatoire, appelée "sel", au texte en clair de la colonne avant de la chiffrer. Si vous souhaitez utiliser la colonne en tant que clé d'index, vous devez spécifier NON SEL. Prière de se référer à Guide de l'administrateur Oracle Advanced Security pour une description de "sel" dans ce contexte.

Restrictions sur la clause ENCRYPT: Les restrictions suivantes s'appliquent au chiffrement de colonne:

  • Pour chiffrer une colonne dans une table externe, la table doit utiliser ORACLE_DATAPUMP comme son type d'accès.

  • Vous ne pouvez pas chiffrer une colonne dans les tables appartenant à SYS.

  • Vous ne pouvez pas chiffrer une colonne de clé étrangère.

Clauses de contrainte

Utilisez ces clauses pour créer des contraintes sur les colonnes de la table. Vous devez spécifier un PRIMAIRE CLÉ contrainte pour une table organisée par index, et il ne peut pas être Reportable. Prière de se référer à contrainte pour la syntaxe et la description de ces contraintes ainsi que des exemples.

inline_ref_constraint et out_of_line_ref_constraint Ces clauses vous permettent de décrire une colonne de type REF. La seule différence entre ces clauses est que vous spécifiez out_of_line_ref_constraint au niveau de la table, vous devez donc identifier le REF colonne ou attribut que vous définissez. Spécifier inline_ref_constraint dans le cadre de la définition du REF colonne ou attribut.

inline_constraiNT Utilisez le inline_constraint définir une contrainte d’intégrité dans la définition de la colonne.

Vous pouvez créer UNIQUE, PRIMAIRE CLÉ, et RÉFÉRENCES contraintes sur les attributs scalaires des colonnes de type d'objet. Vous pouvez également créer NE PAS NUL contraintes sur les colonnes de type d'objet et VÉRIFIER des contraintes qui font référence à des colonnes de type d'objet ou à tout attribut d'une colonne de type d'objet.

out_of_line_constraint Utilisez le out_of_line_constraint syntaxe pour définir une contrainte d'intégrité dans la définition de la table.

supplemental_logging_props

le supplemental_logging_props Cette clause vous permet de charger la base de données de placer des données supplémentaires dans le flux de journaux afin de prendre en charge les outils basés sur les journaux.

supplemental_log_grp_clause Utilisez cette clause pour créer un groupe de journaux nommé.

  • le NON BÛCHE Cette clause vous permet d’omettre du journal de reprise une ou plusieurs colonnes qui seraient autrement incluses dans le rétablissement du groupe de journaux nommé. Vous devez spécifier au moins une colonne de longueur fixe sans NON BÛCHE dans le groupe de journaux nommé.

  • Si vous spécifiez TOUJOURS, puis lors d’une mise à jour, la base de données inclut dans la restauration toutes les colonnes du groupe de journaux. Ceci s'appelle un groupe de journaux inconditionnel (parfois appelé "groupe de journalisation"), car Oracle Database enregistre de manière complémentaire toutes les colonnes du groupe de journalisation lorsque la ligne associée est modifiée. Si vous omettez TOUJOURS, la base de données enregistre ensuite toutes les colonnes du groupe de journaux uniquement si l’une quelconque des colonnes du groupe de journaux est modifiée. Ceci s'appelle un groupe de journaux conditionnel.

Vous pouvez interroger le approprié UTILISATEUR_, TOUT_, ou DBA_LOG_GROUP_COLUMNS dictionnaire de données pour déterminer si une journalisation supplémentaire a déjà été spécifiée.

supplemental_id_key_clause Utilisez cette clause pour spécifier que toutes les colonnes de clé primaire, de clé unique et de clé étrangère, ou une combinaison de celles-ci, doivent être journalisées. Oracle Database générera soit un groupe de journaux inconditionnel ou un groupe de journaux conditionnel. Avec un groupe de journaux inconditionnel, la base de données enregistre de manière supplémentaire toutes les colonnes du groupe de journaux lorsque la ligne associée est modifiée. Avec un groupe de journaux conditionnel, la base de données enregistre de manière complémentaire toutes les colonnes du groupe de journaux uniquement si l'une des colonnes du groupe de journaux est modifiée.

  • Si vous spécifiez TOUT COLONNES, alors la base de données inclut dans le journal de restauration toutes les colonnes de taille maximale de longueur fixe de cette ligne. Un tel journal de rétablissement est un groupe de journaux inconditionnel généré par le système.

  • Si vous spécifiez PRIMAIRE CLÉ COLONNES, puis pour toutes les tables avec une clé primaire, la base de données place dans le journal de restauration toutes les colonnes de la clé primaire chaque fois qu'une mise à jour est effectuée. Oracle Database évalue les colonnes à consigner de manière supplémentaire comme suit:

    • La base de données choisit d’abord les colonnes de la contrainte de clé primaire, si celle-ci est validée ou marquée COMPTER et n'est pas marqué comme DÉSACTIVÉ ou INITIALEMENT DIFFÉRÉ.

    • Si aucune colonne de clé primaire n'existe, la base de données recherche la plus petite UNIQUE index avec au moins un NE PAS NUL colonne et utilise les colonnes de cet index.

    • Si aucun index de ce type n'existe, la base de données enregistre ensuite toutes les colonnes scalaires de la table.

  • Si vous spécifiez UNIQUE COLONNES, puis pour toutes les tables avec une clé unique ou un index bitmap, si l’une quelconque des colonnes d’index clé unique ou bitmap est modifiée, la base de données place dans le journal de restauration toutes les autres colonnes appartenant à la clé unique ou à l’index bitmap. Un tel groupe de journaux est un groupe de journaux conditionnel généré par le système.

  • Si vous spécifiez ÉTRANGER CLÉ COLONNES, puis pour toutes les tables avec une clé étrangère, si des colonnes de clé étrangère sont modifiées, la base de données place dans le journal de restauration toutes les autres colonnes appartenant à la clé étrangère. Un tel journal de rétablissement est un groupe de journaux conditionnel généré par le système.

Si vous spécifiez cette clause plusieurs fois, la base de données crée un groupe de journaux distinct pour chaque spécification. Vous pouvez interroger le approprié UTILISATEUR_, TOUT_, ou DBA_LOG_GROUPS dictionnaire de données pour déterminer si des données de journalisation supplémentaires ont déjà été spécifiées.

SUR COMMETTRE

le SUR COMMETTRE La clause n'est pertinente que si vous créez une table temporaire. Cette clause spécifie si les données de la table temporaire sont conservées pendant la durée d'une transaction ou d'une session.

SUPPRIMER LES RANGES Spécifier EFFACER LIGNES pour une table temporaire spécifique à une transaction. C'est la valeur par défaut. Oracle Database tronquera la table (supprimera toutes ses lignes) après chaque validation.

Préserver les rangs Spécifier PRÉSERVER LIGNES pour une table temporaire spécifique à la session. Oracle Database tronque la table (supprime toutes ses lignes) lorsque vous terminez la session.

propriétés physiques

Les propriétés physiques concernent le traitement des étendues et des segments et les caractéristiques de stockage de la table.

segment_attributes_clause

le segment_attributes_clause vous permet de spécifier les attributs physiques et le stockage d'espace table pour la table.

clause_attributs_ physiques le clause_attributs_ physiques vous permet de spécifier la valeur du PCTFREE, PCTUSED, et INITRANS paramètres et les caractéristiques de stockage de la table.

  • Pour une table non partitionnée, chaque paramètre et caractéristique de stockage que vous spécifiez détermine l'attribut physique réel du segment associé à la table.

  • Pour les tables partitionnées, la valeur que vous spécifiez pour le paramètre ou la caractéristique de stockage est l'attribut physique par défaut des segments associés à toutes les partitions spécifiées dans cette section. CRÉER déclaration (et dans la suite MODIFIER TABLEAJOUTER CLOISON instructions), sauf si vous écrasez explicitement cette valeur dans CLOISON clause de l'instruction qui crée la partition.

Si vous omettez cette clause, Oracle Database définit PCTFREE à 10, PCTUSED à 40, et INITRANS à 1.

TABLESPACE Spécifiez l'espace de table dans lequel Oracle Database crée la table, table d'objet OIDINDEX, partition, segment de données LOB, segment d'index LOB ou segment de données de dépassement de table organisé par index. Si vous omettez TABLESPACE, puis la base de données crée cet élément dans l’espace table par défaut du propriétaire du schéma contenant la table.

Pour une table organisée en tas avec une ou plusieurs colonnes LOB, si vous omettez le TABLESPACE clause de stockage LOB, la base de données crée les segments de données LOB et d’index dans le tablespace où la table est créée.

Pour une table organisée par index avec une ou plusieurs colonnes LOB, si vous omettez TABLESPACE, puis les segments de données et d'index LOB sont créés dans l'espace de table dans lequel le segment d'index de clé primaire de la table organisée par index est créé.

Pour les tables non partitionnées, la valeur spécifiée pour TABLESPACE est l'attribut physique réel du segment associé à la table. Pour les tables partitionnées, la valeur spécifiée pour TABLESPACE est l'attribut physique par défaut des segments associés à toutes les partitions spécifiées dans le champ CRÉER déclaration et à la suite MODIFIER TABLEAJOUTER CLOISON déclarations, sauf si vous spécifiez TABLESPACE dans le CLOISON la description.

clause_logging

Indiquez si la création de la table et de tout index requis en raison de contraintes, de caractéristiques de partition ou de stockage LOB sera consignée dans le fichier journal redo (ENREGISTREMENT) ou pas (NOLOGGING). L’attribut de journalisation de la table est indépendant de celui de ses index.

Cet attribut indique également si le chargeur direct ultérieur (SQL * Loader) et le chemin direct INSÉRER les opérations sur la table, la partition ou le stockage LOB sont consignées (ENREGISTREMENT) ou non connecté (NOLOGGING).

Prière de se référer à clause_logging pour une description complète de cette clause.

compression_table

le compression_table La clause n'est valide que pour les tables organisées par tas. Utilisez cette clause pour indiquer à la base de données s'il faut compresser les segments de données pour réduire l'utilisation du disque. Cette clause est particulièrement utile dans des environnements tels que les entrepôts de données, où le nombre d'opérations d'insertion et de mise à jour est faible. le COMPRESSE mot clé active la compression de table. le NOCOMPRESS mot clé désactive la compression de la table. NOCOMPRESS est la valeur par défaut.

Lorsque vous activez la compression de table, Oracle Database tente de compresser les données lors d'un accès direct. INSÉRER opérations quand il est productif de le faire. L'utilitaire d'importation d'origine (imp) ne prend pas en charge le chemin direct. INSÉRERet ne peut donc pas importer des données dans un format compressé. Vous pouvez spécifier une compression de table pour les parties suivantes d'une table organisée par tas:

  • Pour une table entière, dans le propriétés physiques clause de table_relationnelle ou objet_table

  • For a range partition, in the table_partition_description du range_partitioning clause

  • For a list partition, in the table_partition_description du list_partitioning clause

  • For the storage table of a nested table, in the nested_table_col_properties clause

Restrictions on Table Compression Table compression is subject to the following restrictions:

  • Table compression is not supported for tables with more than 255 columns.

  • LOB data segments are not compressed.

  • You cannot specify table compression for an index-organized table, any overflow segment or partition of an overflow segment, or any mapping table segment of an index-organized table.

  • You cannot define table compression explicitly for hash partitions or hash and list subpartitions. The table compression attribute for those partitions is inherited from the tablespace, the table, or the table partition setting.

  • You cannot specify table compression for external tables or for tables that are part of a cluster.

RECOVERABLE | UNRECOVERABLE

These keywords are deprecated and have been replaced with LOGGING et NOLOGGING, respectivement. Bien que RECOVERABLE et UNRECOVERABLE are supported for backward compatibility, Oracle strongly recommends that you use the LOGGING et NOLOGGING keywords.

Restrictions on [UN]RECOVERABLE This clause is subject to the following restrictions:

  • You cannot specify RECOVERABLE for partitioned tables or LOB storage characteristics.

  • You cannot specify UNRECOVERABLE for partitioned or index-organized tables.

  • You can specify UNRECOVERABLE only with COMME subquery.

ORGANIZATION

le ORGANIZATION clause lets you specify the order in which the data rows of the table are stored.

HEAP HEAP indicates that the data rows of table are stored in no particular order. This is the default.

INDEX INDEX indicates that table is created as an index-organized table. In an index-organized table, the data rows are held in an index defined on the primary key for the table.

EXTERNAL EXTERNAL indicates that table is a read-only table located outside the database.

index_org_table_clause

Utilisez le index_org_table_clause to create an index-organized table. Oracle Database maintains the table rows, both primary key column values and nonkey column values, in an index built on the primary key. Index-organized tables are therefore best suited for primary key-based access and manipulation. An index-organized table is an alternative to:

  • A noncluster table indexed on the primary key by using the CREATE INDEX déclaration

  • A cluster table stored in an indexed cluster that has been created using the CREATE CLUSTER statement that maps the primary key for the table to the cluster key

You must specify a primary key for an index-organized table, because the primary key uniquely identifies a row. The primary key cannot be DEFERRABLE. Use the primary key instead of the rowid for directly accessing index-organized rows.

If an index-organized table is partitioned and contains LOB columns, then you should specify the index_org_table_clause first, then the LOB_storage_clause, and then the appropriate table_partitioning_clauses.

You cannot use the TO_LOB function to convert a LONG column to a LOB column in the subquery of a CREATE TABLECOMME SELECT statement if you are creating an index-organized table. Instead, create the index-organized table without the LONG column, and then use the TO_LOB function in an INSÉRERCOMME SELECT déclaration.

Restrictions on Index-Organized Tables Index-organized tables are subject to the following restrictions:

PCTTHRESHOLD entier Specify the percentage of space reserved in the index block for an index-organized table row. PCTTHRESHOLD must be large enough to hold the primary key. All trailing columns of a row, starting with the column that causes the specified threshold to be exceeded, are stored in the overflow segment. PCTTHRESHOLD must be a value from 1 to 50. If you do not specify PCTTHRESHOLD, the default is 50.

Restriction on PCTTHRESHOLD You cannot specify PCTTHRESHOLD for individual partitions of an index-organized table.

mapping_table_clauses Specify MAPPING TABLE to instruct the database to create a mapping of local to physical ROWIDs and store them in a heap-organized table. This mapping is needed in order to create a bitmap index on the index-organized table. If the index-organized table is partitioned, then the mapping table is also partitioned and its partitions have the same name and physical attributes as the base table partitions.

Oracle Database creates the mapping table or mapping table partition in the same tablespace as its parent index-organized table or partition. You cannot query, perform DML operations on, or modify the storage characteristics of the mapping table or its partitions.

key_compression le key_compression clauses let you enable or disable key compression for index-organized tables.

  • Specify COMPRESS to enable key compression, which eliminates repeated occurrence of primary key column values in index-organized tables. Utilisation entier to specify the prefix length, which is the number of prefix columns to compress.

    The valid range of prefix length values is from 1 to the number of primary key columns minus 1. The default prefix length is the number of primary key columns minus 1.

  • Specify NOCOMPRESS to disable key compression in index-organized tables. This is the default.

Restriction on Key Compression of Index-organized Tables At the partition level, you can specify COMPRESS, but you cannot specify the prefix length with entier.

index_org_overflow_clause le index_org_overflow_clause lets you instruct the database that index-organized table data rows exceeding the specified threshold are placed in the data segment specified in this clause.

  • When you create an index-organized table, Oracle Database evaluates the maximum size of each column to estimate the largest possible row. If an overflow segment is needed but you have not specified OVERFLOW, then the database raises an error and does not execute the CREATE TABLE déclaration. This checking function guarantees that subsequent DML operations on the index-organized table will not fail because an overflow segment is lacking.

  • All physical attributes and storage characteristics you specify in this clause after the OVERFLOW keyword apply only to the overflow segment of the table. Physical attributes and storage characteristics for the index-organized table itself, default values for all its partitions, and values for individual partitions must be specified before this keyword.

  • If the index-organized table contains one or more LOB columns, then the LOBs will be stored out-of-line unless you specify OVERFLOW, even if they would otherwise be small enough be to stored inline.

  • Si table is partitioned, then the database equipartitions the overflow data segments with the primary key index segments.

INCLUDING column_name Specify a column at which to divide an index-organized table row into index and overflow portions. The primary key columns are always stored in the index. column_name can be either the last primary key column or any non primary key column. All non primary key columns that follow column_name are stored in the overflow data segment.

If an attempt to divide a row at column_name causes the size of the index portion of the row to exceed the specified or default PCTTHRESHOLD value, then the database breaks up the row based on the PCTTHRESHOLD valeur.

Restriction on the INCLUDING Clause You cannot specify this clause for individual partitions of an index-organized table.

external_table_clause

Utilisez le external_table_clause to create an external table, which is a read-only table whose metadata is stored in the database but whose data in stored outside the database. Among other capabilities, external tables let you query data without first loading it into the database.

Because external tables have no data in the database, you define them with a small subset of the clauses normally available when creating tables.

  • Within the relational_properties clause, you can specify only colonne et datatype.

  • Within the physical_properties_clause, you can specify only the organization of the table (ORGANIZATION EXTERNAL external_table_clause).

  • Within the table_properties clause, you can specify only the parallel_clause. le parallel_clause lets you parallelize subsequent queries on the external data and subsequent operations that populate the external table.

  • You can populate the external table at create time by using the COMME subquery clause.

No other clauses are permitted in the same CREATE TABLE déclaration.

Restrictions on External Tables External tables are subject to the following restrictions:

  • An external table cannot be a temporary table.

  • You cannot specify constraints on an external table.

  • An external table cannot have object type, varray, or LONG columns. However, you can populate LOB columns of an external table with varray or LONG data from an internal database table.

TYPE TYPE access_driver_type indicates the access driver of the external table. The access driver is the API that interprets the external data for the database. Oracle Database provides two access drivers: ORACLE_LOADER et ORACLE_DATAPUMP. If you do not specify TYPE, then the database uses ORACLE_LOADER as the default access driver. You must specify the ORACLE_DATAPUMP access driver if you specify the COMME subquery clause to unload data from one Oracle Database and reload it into the same or a different Oracle Database.

DEFAULT DIRECTORY DEFAULT DIRECTORY lets you specify a default directory object corresponding to a directory on the file system where the external data sources may reside. The default directory can also be used by the access driver to store auxiliary files such as error logs.

ACCESS PARAMETERS The optional ACCESS PARAMETERS clause lets you assign values to the parameters of the specific access driver for this external table.

  • le opaque_format_spec lets you list the parameters and their values. Please refer to Oracle Database Utilities for information on how to specify values for the opaque_format_spec.

    Field names specified in the opaque_format_spec must match columns in the table definition. Oracle Database ignores any field in the opaque_format_spec that is not matched by a column in the table definition.

  • USING CLOB subquery lets you derive the parameters and their values through a subquery. The subquery cannot contain any set operators or an ORDER PAR clause. It must return one row containing a single item of datatype CLOB.

Whether you specify the parameters in an opaque_format_spec or derive them using a subquery, the database does not interpret anything in this clause. It is up to the access driver to interpret this information in the context of the external data.

EMPLACEMENT le EMPLACEMENT clause lets you specify one or more external data sources. Usually the location_specifier is a file, but it need not be. Oracle Database does not interpret this clause. It is up to the access driver to interpret this information in the context of the external data. You cannot use wildcards in the location_specifier to specify multiple files.

REJECT LIMIT le REJECT LIMIT clause lets you specify how many conversion errors can occur during a query of the external data before an Oracle Database error is returned and the query is aborted. The default value is 0.

CLUSTER Clause

le CLUSTER clause indicates that the table is to be part of cluster. The columns listed in this clause are the table columns that correspond to the cluster columns. Generally, the cluster columns of a table are the column or columns that make up its primary key or a portion of its primary key. Please refer to CREATE CLUSTER for more information.

Specify one column from the table for each column in the cluster key. The columns are matched by position, not by name.

A cluster table uses the space allocation of the cluster. Therefore, do not use the PCTFREE, PCTUSED, ou INITRANS parameters, the TABLESPACE clause, or the storage_clause avec le CLUSTER clause.

Restrictions on Cluster Tables Cluster tables are subject to the following restrictions:

  • Object tables and tables containing LOB columns cannot be part of a cluster.

  • You cannot specify CLUSTER with either ROWDEPENDENCIES ou NOROWDEPENDENCIES unless the cluster has been created with the same ROWDEPENDENCIES ou NOROWDEPENDENCIES réglage.

table_properties

le table_properties further define the characteristics of the table.

column_properties

Utilisez le column_properties clauses to specify the storage attributes of a column.

object_type_col_properties

le object_type_col_properties determine storage characteristics of an object column or attribute or of an element of a collection column or attribute.

colonne Pour colonne, specify an object column or attribute.

substitutable_column_clause le substitutable_column_clause indicates whether object columns or attributes in the same hierarchy are substitutable for each other. You can specify that a column is of a particular type, or whether it can contain instances of its subtypes, or both.

  • If you specify ÉLÉMENT, you constrain the element type of a collection column or attribute to a subtype of its declared type.

  • le IS OF [TYPE] (ONLY type) clause constrains the type of the object column to a subtype of its declared type.

  • NE PAS SUBSTITUTABLE À TOUT LEVELS indicates that the object column cannot hold instances corresponding to any of its subtypes. Also, substitution is disabled for any embedded object attributes and elements of embedded nested tables and varrays. The default is SUBSTITUTABLE À TOUT LEVELS.

Restrictions on the substitutable_column_clause This clause is subject to the following restrictions:

  • You cannot specify this clause for an attribute of an object column. However, you can specify this clause for a object type column of a relational table and for an object column of an object table if the substitutability of the object table itself has not been set.

  • For a collection type column, the only part of this clause you can specify is [NOT] SUBSTITUTABLE À TOUT LEVELS.

LOB_storage_clause

le LOB_storage_clause lets you specify the storage attributes of LOB data segments.

For a nonpartitioned table, this clause specifies the storage attributes of LOB data segments of the table.

For a partitioned table, Oracle Database implements this clause depending on where it is specified:

  • For a partitioned table specified at the table level–that is, when specified in the physical_properties clause along with one of the partitioning clauses–this clause specifies the default storage attributes for LOB data segments associated with each partition or subpartition. These storage attributes apply to all partitions or subpartitions unless overridden by a LOB_storage_clause at the partition or subpartition level.

  • For an individual partition of a partitioned table–that is, when specified as part of a table_partition_description–this clause specifies the storage attributes of the data segments of the partition or the default storage attributes of any subpartitions of the partition. A partition-level LOB_storage_clause overrides a table-level LOB_storage_clause.

  • For an individual subpartition of a partitioned table–that is, when specified as part of subpartition_by_hash ou subpartition_by_list–this clause specifies the storage attributes of the data segments of the subpartition. A subpartition-level LOB_storage_clause overrides both partition-level and table-level LOB_storage_clauses.

LOB_item

Specify the LOB column name or LOB object attribute for which you are explicitly defining tablespace and storage characteristics that are different from those of the table. Oracle Database automatically creates a system-managed index for each LOB_item you create.

LOB_segname

Specify the name of the LOB data segment. You cannot use LOB_segname if you specify more than one LOB_item.

LOB_parameters

le LOB_parameters clause lets you specify various elements of LOB storage.

ENABLE STORAGE IN ROW If you enable storage in row, then the LOB value is stored in the row (inline) if its length is less than approximately 4000 bytes minus system control information. This is the default.

Restriction on Enabling Storage in Row For an index-organized table, you cannot specify this parameter unless you have specified an OVERFLOW segment in the index_org_table_clause.

DISABLE STORAGE IN ROW If you disable storage in row, then the LOB value is stored outside of the row out of line regardless of the length of the LOB value.

The LOB locator is always stored inline regardless of where the LOB value is stored. You cannot change the value of ESPACE DE RANGEMENT DANS ROW once it is set except by moving the table. See the move_table_clause dans le MODIFIER TABLE documentation for more information.

CHUNK entier Specify the number of bytes to be allocated for LOB manipulation. Si entier is not a multiple of the database block size, then the database rounds up in bytes to the next multiple. For example, if the database block size is 2048 and entier is 2050, then the database allocates 4096 bytes (2 blocks). The maximum value is 32768 (32K), which is the largest Oracle Database block size allowed. The default CHUNK size is one Oracle Database block.

The value of CHUNK must be less than or equal to the value of NEXT, either the default value or that specified in the storage_clause. Si CHUNK exceeds the value of NEXT, then the database returns an error.You cannot change the value of CHUNK once it is set.

PCTVERSION entier Specify the maximum percentage of overall LOB storage space used for maintaining old versions of the LOB. The default value is 10, meaning that older versions of the LOB data are not overwritten until they consume 10% of the overall LOB storage space.

You can specify the PCTVERSION parameter whether the database is running in manual or automatic undo mode. PCTVERSION is the default in manual undo mode. RETENTION is the default in automatic undo mode. You cannot specify both PCTVERSION et RETENTION.

RETENTION Use this clause to indicate that Oracle Database should retain old versions of this LOB column. Oracle Database uses the value of the UNDO_RETENTION initialization parameter to determine the amount of committed undo data to retain in the database.

You can specify the RETENTION parameter only if the database is running in automatic undo mode. In this mode, RETENTION is the default value unless you specify PCTVERSION. You cannot specify both PCTVERSION et RETENTION.

FREEPOOLS entier Specify the number of groups of free lists for the LOB segment. Normalement entier will be the number of instances in a Real Application Clusters environment or 1 for a single-instance database.

You can specify this parameter only if the database is running in automatic undo mode. In this mode, FREEPOOLS is the default unless you specify the FREELIST GROUPS parameter of the storage_clause. If you specify neither FREEPOOLS nor FREELIST GROUPS, then the database uses a default of FREEPOOLS 1 if the database is in automatic undo management mode and a default of FREELIST GROUPS 1 if the database is in manual undo management mode.

Restriction on FREEPOOLS You cannot specify both FREEPOOLS et le FREELIST GROUPS parameter of the storage_clause.

varray_col_properties

le varray_col_properties let you specify separate storage characteristics for the LOB in which a varray will be stored. Si varray_item is a multilevel collection, then the database stores all collection items nested within varray_item in the same LOB in which varray_item is stored.

  • For a nonpartitioned table–that is, when specified in the physical_properties clause without any of the partitioning clauses–this clause specifies the storage attributes of the LOB data segments of the varray.

  • For a partitioned table specified at the table level–that is, when specified in the physical_properties clause along with one of the partitioning clauses–this clause specifies the default storage attributes for the varray LOB data segments associated with each partition (or its subpartitions, if any).

  • For an individual partition of a partitioned table–that is, when specified as part of a table_partition_description–this clause specifies the storage attributes of the varray LOB data segments of that partition or the default storage attributes of the varray LOB data segments of any subpartitions of this partition. A partition-level varray_col_properties overrides a table-level varray_col_properties.

  • For an individual subpartition of a partitioned table–that is, when specified as part of subpartition_by_hash ou subpartition_by_list–this clause specifies the storage attributes of the varray data segments of this subpartition. A subpartition-level varray_col_properties overrides both partition-level and table-level varray_col_properties.

STORE AS LOB Clause If you specify STORE COMME LOB:

  • If the maximum varray size is less than 4000 bytes, then the database stores the varray as an inline LOB unless you have disabled storage in row.

  • If the maximum varray size is greater than 4000 bytes or if you have disabled storage in row, then the database stores in the varray as an out-of-line LOB.

If you do not specify STORE COMME LOB, then storage is based on the maximum possible size of the varray rather than on the actual size of a varray column. The maximum size of the varray is the number of elements times the element size, plus a small amount for system control information. If you omit this clause:

  • If the maximum size of the varray is less than 4000 bytes, then the database does not store the varray as a LOB, but as inline data.

  • If the maximum size is greater than 4000 bytes, then the database always stores the varray as a LOB.

    • If the actual size is less than 4000 bytes, it is stored as an inline LOB

    • If the actual size is greater than 4000 bytes, it is stored as an out-of-line LOB, as is true for other LOB columns.

Restriction on Storing Varrays as LOBs You cannot specify the TABLESPACE parameter of LOB_parameters as part of this clause. The LOB tablespace for a varray defaults to the tablespace of the containing table or table partition.

substitutable_column_clause le substitutable_column_clause has the same behavior as described for object_type_col_properties.

nested_table_col_properties

le nested_table_col_properties let you specify separate storage characteristics for a nested table, which in turn enables you to define the nested table as an index-organized table. Unless you explicitly specify otherwise in this clause:

  • For a nonpartitioned table, the storage table is created in the same schema and the same tablespace as the parent table.

  • For a partitioned table, the storage table is created in the default tablespace of the schema.

  • In either case, the storage table uses default storage characteristics, and stores the nested table values of the column for which it was created.

You must include this clause when creating a table with columns or column attributes whose type is a nested table. Clauses within nested_table_col_properties that function the same way they function for the parent table are not repeated here.

nested_item Specify the name of a column, or of a top-level attribute of the object type of the tables, whose type is a nested table.

COLUMN_VALUE If the nested table is a multilevel collection, then the inner nested table or varray may not have a name. In this case, specify COLUMN_VALUE in place of the nested_item name.

storage_table Specify the name of the table where the rows of nested_item reside.

You cannot query or perform DML statements on storage_table directly, but you can modify its storage characteristics by specifying its name in an MODIFIER TABLE déclaration.

Restriction on the Storage Table You cannot partition the storage table of a nested table.

Voir également:

ALTER TABLE for information about modifying nested table column storage characteristics

RETURN AS Specify what Oracle Database returns as the result of a query.

  • VALUE returns a copy of the nested table itself.

  • LOCATOR returns a collection locator to the copy of the nested table.

    The locator is scoped to the session and cannot be used across sessions. Unlike a LOB locator, the collection locator cannot be used to modify the collection instance.

If you do not specify the segment_attributes_clause ou la LOB_storage_clause, then the nested table is heap organized and is created with default storage characteristics.

Restrictions on Nested Table Column Properties Nested table column properties are subject to the following restrictions:

  • You cannot specify this clause for a temporary table.

  • You cannot specify the oid_clause.

  • At create time, you cannot use object_properties to specify an out_of_line_ref_constraint, inline_ref_constraint, or foreign key constraint for the attributes of a nested table. However, you can modify a nested table to add such constraints using MODIFIER TABLE.

XMLType_column_properties

le XMLType_column_properties let you specify storage attributes for an XMLTYPE column.

XMLType_storage XMLType columns can be stored either in LOB or object-relational columns.

  • Specify STORE COMME OBJECT RELATIONAL if you want the database to store the XMLType data in object-relational columns. Storing data objects relationally lets you define indexes on the relational columns and enhances query performance.

    If you specify object-relational storage, then you must also specify the XMLSchema_spec clause.

  • Specify STORE COMME CLOB if you want the database to store the XMLType data in a CLOB column. Storing data in a CLOB column preserves the original content and enhances retrieval time.

    If you specify LOB storage, then you can specify either LOB parameters or the XMLSchema_spec clause, but not both. Specify the XMLSchema_spec clause if you want to restrict the table or column to particular schema-based XML instances.

XMLSchema_spec This clause lets you specify the URL of a registered XMLSchema, either in the XMLSCHEMA clause or as part of the ÉLÉMENT clause, and an XML element name. You must specify an element, although the XMLSchema URL is optional. If you do specify an XMLSchema URL, then you must already have registered the XMLSchema using the DBMS_XMLSCHEMA package.

table_partitioning_clauses

Utilisez le table_partitioning_clauses to create a partitioned table.

Restrictions on Partitioning in General All partitioning is subject to the following restrictions:

The storage of partitioned database entities in tablespaces of different block sizes is subject to several restrictions. Please refer to Oracle Database Administrator's Guide for a discussion of these restrictions.

range_partitioning

Utilisez le range_partitioning clause to partition the table on ranges of values from the column list. For an index-organized table, the column list must be a subset of the primary key columns of the table.

colonne

Specify an ordered list of columns used to determine into which partition a row belongs. These columns are the partitioning key.

Restriction on Partitioning Key Columns The columns in the column list can be of any built-in datatype except ROWID, LONG, LOB, ou TIMESTAMP AVEC TEMPS ZONE. However, columns of TIMESTAMP ou TIMESTAMP AVEC LOCAL TEMPS ZONE can be used in the partitioning key.

PARTITION cloison

The name cloison must conform to the rules for naming schema objects and their part as described in "Schema Object Naming Rules". If you omit cloison, then the database generates a name with the form SYS_Pn.

  • You can specify up to a total of 1024K-1 partitions and subpartitions. For a discussion of factors that might impose practical limits less than this number, please refer to Oracle Database Administrator's Guide.

  • You can create a partitioned table with just one partition. However, this is different from a nonpartitioned table. For instance, you cannot add a partition to a nonpartitioned table.

range_values_clause

Specify the noninclusive upper bound for the current partition. The value list is an ordered list of literal values corresponding to the column list in the range_partitioning clause. You can substitute the keyword MAXVALUE for any literal in in the value list. MAXVALUE specifies a maximum value that will always sort higher than any other value, including null.

Specifying a value other than MAXVALUE for the highest partition bound imposes an implicit integrity constraint on the table.

Remarque:

Si table is partitioned on a DATE column, and if the date format does not specify the first two digits of the year, then you must use the TO_DATE function with the YYYY 4-character format mask for the year. le RRRR format mask is not supported in this clause. The date format is determined implicitly by NLS_TERRITORY or explicitly by NLS_DATE_FORMAT. Please refer to Oracle Database Globalization Support Guide for more information on these initialization parameters.

table_partition_description

Utilisez le table_partition_description to define the physical and storage characteristics of the table.

le segment_attributes_clause et table_compression clause have the same function as described for the table_properties of the table as a whole.

le key_compression clause and OVERFLOW clause have the same function as described for the index_org_table_clause .

LOB_storage_clause le LOB_storage_clause lets you specify LOB storage characteristics for one or more LOB items in this partition or in any list subpartitions of this partition. If you do not specify the LOB_storage_clause for a LOB item, then the database generates a name for each LOB data partition. The system-generated names for LOB data and LOB index partitions take the form SYS_LOB_Pn et SYS_IL_Pn, respectivement. The corresponding system-generated names for LOB data and index subpartitions are SYS_LOB_SUBPn et SYS_IL_SUBPn, respectively

varray_col_properties le varray_col_properties let you specify storage characteristics for one or more varray items in this partition or in any list subpartitions of this partition.

Restriction on table_partition_description le partition_level_subpartition clause is valid only for composite-partitioned tables. See partition_level_subpartition.

hash_partitioning

Utilisez le hash_partitioning clause to specify that the table is to be partitioned using the hash method.

Oracle Database assigns rows to partitions using a hash function on values found in columns designated as the partitioning key. You can specify individual hash partitions or you can specify how many subpartitions the database should create.

colonne Specify an ordered list of columns used to determine into which partition a row belongs (the partitioning key).

individual_hash_partitions Use this clause to specify individual partitions by name. If you omit the partition name, then the database assigns partition names of the form SYS_Pn.

Restriction on Specifying Individual Hash Partitions The only clause you can specify in the partitioning_storage_clause est le TABLESPACE clause.

Remarque:

If your enterprise has or will have databases using different character sets, use caution when partitioning on character columns. The sort sequence of characters is not identical in all character sets. Please refer to Oracle Database Globalization Support Guide for more information on character set support.

hash_partitions_by_quantity Alternatively, you can specify the number of partitions. In this case, the database assigns partition names of the form SYS_Pn. le STORE DANS clause specifies one or more tablespaces where the hash partitions are to be stored. The number of tablespaces does not have to equal the number of partitions. If the number of partitions is greater than the number of tablespaces, then the database cycles through the names of the tablespaces.

For both methods of hash partitioning, for optimal load balancing you should specify a number of partitions that is a power of 2. Also for both methods of hash partitioning, the only attribute you can specify for hash partitions is TABLESPACE. Hash partitions inherit all other attributes from table-level defaults.

Tablespace storage specified at the table level is overridden by tablespace storage specified at the partition level, which in turn is overridden by tablespace storage specified at the subpartition level.

dans le individual_hash_partitions clause, the TABLESPACE clause of the partitioning_storage_clause determines tablespace storage only for the individual partition being created. dans le hash_partitions_by_quantity clause, the STORE DANS clause determines placement of partitions as the table is being created and the default storage location for subsequently added partitions.

Restrictions on Hash Partitioning Hash partitioning is subject to the following restrictions:

  • You cannot specify more than 16 partitioning columns.

  • The column list cannot contain the ROWID ou UROWID pseudocolumns.

  • The column list can be of any built-in datatype except ROWID, LONG, or LOB.

list_partitioning

Utilisez le list_partitioning clause to partition the table on lists of literal values from colonne. List partitioning is useful for controlling how individual rows map to specific partitions.

If you omit the partition name, then the database assigns partition names of the form SYS_Pn.

list_values_clause le list_values_clause of each partition must have at least one value. No value, including NULL, can appear in more than one partition. List partitions are not ordered.

If you specify the literal NULL for a partition value in the VALUES clause, then to access data in that partition in subsequent queries, you must use an IS NULL condition in the clause, rather than a comparison condition.

le DEFAULT keyword creates a partition into which the database will insert any row that does not map to another partition. Therefore, you can specify DEFAULT for only one partition, and you cannot specify any other values for that partition. Further, the default partition must be the last partition you define. The use of DEFAULT is similar to the use of MAXVALUE for range partitions.

The string comprising the list of values for each partition can be up to 4K bytes. The total number of values for all partitions cannot exceed 64K-1.

Restrictions on List Partitioning List partitioning is subject to the following restrictions:

  • You cannot subpartition a list partition.

  • You can specify only one partitioning key in column_list, and it cannot be a LOB column.

  • If the partitioning key is an object type column, then you can partition on only one attribute of the column type.

  • Each value in the list_values_clause must be unique among all partitions of table.

composite_partitioning

Utilisez le composite_partitioning clause to first partition table by range, and then partition the partitions further into hash or list subpartitions. This combination of range partitioning and hash or list subpartitioning is called composite partitioning.

After establishing the type of subpartitioning you want for each composite partition, using the subpartition_by_hash ou subpartition_by_list clause, you must define each of the range partitions.

  • You must specify the range_values_clause , which has the same requirements as for noncomposite range partitions.

  • Utilisez le table_partition_description to define the physical and storage characteristics of the each partition. Within the table_partition_description, you can use the partition_level_subpartition clause to define the properties of individual subpartitions.

  • If you omit the partition name, then the database generates a name with the form SYS_Pn.

  • The only characteristic you can specify for a hash or list subpartition or a LOB subpartition is TABLESPACE.

Restriction on Composite Partitioning You cannot specify composite partitioning for an index-organized table. Therefore, the OVERFLOW clause of the table_partition_description is not valid for composite-partitioned tables.

subpartition_template le subpartition_template is an optional element of both range-hash and range-list composite partitioning. The template lets you define default subpartitions for each table partition. Oracle Database will create these default subpartitions in any partition for which you do not explicitly define subpartitions. This clause is useful for creating symmetric partitions. You can override this clause by explicitly defining subpartitions at the partition level, in the partition_level_subpartition clause.

When defining subpartitions with a template, you must specify a name for each subpartition.

Remarque:

When you specify tablespace storage for the subpartition template, it does not override any tablespace storage you have specified explicitly for the partitions of table. To specify tablespace storage for subpartitions, do one of these things:

  • Omit tablespace storage at the partition level and specify tablespace storage in the subpartition template.

  • Define individual subpartitions with specific tablespace storage.

Restrictions on Subpartition Templates Subpartition templates are subject to the following restrictions:

  • For a range-hash composite-partitioned table, you cannot specify the list_values_clause.

  • For a range-list composite-partitioned table, you cannot specify the hash_subpartition_quantity clause.

  • For both range-hash and range-list partitioned tables, the only clause of the partitioning_storage_clause you can specify for subpartitions is the TABLESPACE clause.

  • If you specify TABLESPACE for one subpartition, then you must specify TABLESPACE for all subpartitions. You can specify the same tablespace for more than one subpartition.

  • If you specify TABLESPACE for one LOB subpartition, then you must specify TABLESPACE for all of the LOB subpartitions of that LOB column. You can specify the same tablespace for more than one LOB subpartition.

  • If you specify separate LOB storage for list subpartitions using the partitioning_storage_clause, either in the subpartition_template or when defining individual subpartitions, then you must specify LOB_segname for both LOB and varray columns.

subpartition_by_hash

Utilisez le subpartition_by_hash clause to indicate that the database should subpartition by hash each partition in table. The subpartitioning column list is unrelated to the partitioning key but is subject to the same restrictions (see colonne).

You can define the subpartitions using the subpartition_template ou la SUBPARTITIONS quantité clause. See subpartition_template. In either case, for optimal load balancing you should specify a number of partitions that is a power of 2.

SUBPARTITIONS quantité Specify the default number of subpartitions in each partition of table, and optionally one or more tablespaces in which they are to be stored.

The default value is 1. If you omit both this clause and subpartition_template, then the database will create each partition with one hash subpartition unless you subsequently specify the partition_level_subpartition clause.

Restriction on Hash Subpartitioning In addition to the restrictions for composite partitioning in general (see composite_partitioning ), for hash subpartitioning in subpartition_template, you cannot specify the list_values_clause.

subpartition_by_list

Utilisez le subpartition_by_list clause to indicate that the database should subpartition each partition in table by literal values from colonne.

If you omit subpartition_template, then you can define list subpartitions individually for each partition using the partition_level_subpartition clause of table_partition_description. If you omit both subpartition_template et partition_level_subpartition, then the database creates a single DEFAULT subpartition.

Restrictions on List Subpartitioning List subpartitioning is subject to the following restrictions:

In addition to the restrictions for composite partitioning in general (see composite_partitioning ), for list subpartitioning:

  • You can specify only one subpartitioning key column.

  • You must specify the list_values_clause, which is subject to the same requirements as at the table level.

  • dans le subpartition_template, you cannot specify the hash_subpartition_quantity clause.

partition_level_subpartition

This clause of the table_partition_description is valid only for composite-partitioned tables. This clause lets you specify hash or list subpartitions for cloison. This clause overrides the default settings established for range-hash composite partitions in the subpartition_by_hash clause or for range-hash or range-list composite partitions in the subpartition_template.

Notes on Composite Partitions The following notes apply to composite partitions:

  • You can specify the number of subpartitions and optionally one or more tablespaces where they are to be stored. In this case, Oracle Database assigns subpartition names of the form SYS_SUBPn. The number of tablespaces does not have to equal the number of subpartitions. If the number of partitions is greater than the number of tablespaces, then the database cycles through the names of the tablespaces.

  • Alternatively, you can use the subpartition_spec to specify individual subpartitions by name, and optionally the tablespace where each should be stored.

  • If you omit partition_level_subpartition and if you have created a subpartition template, then the database uses the template to create subpartitions. If you have not created a subpartition template, then the database creates one hash subpartition or one DEFAULT list subpartition.

  • If you omit partition_level_subpartition entirely, then the database assigns subpartition names as follows:

    • If you have specified a subpartition template et you have specified partition names, then the database generates subpartition names of the form partition_name underscore (_) subpartition_name (for example, P1_SUB1).

    • If you have not specified a subpartition template ou if you have specified a subpartition template but did not specify partition names, then the database generates subpartition names of the form SYS_SUBPn.

  • Dans partition_spec, the only clause of the partitioning_storage_clause you can specify is the TABLESPACE clause.

For range-hash composite partitions, the list_values_clause de subpartition_spec is not relevant and is invalid.

For range-list composite partitions:

  • le hash_subpartition_quantity is not relevant, so you specify subpartition_spec.

  • Within subpartition_spec, you must specify the list_values_clause for each subpartition, and the values you specify for each subpartition cannot exist in any other subpartition of the same partition.

CACHE | NOCACHE | CACHE READS

Utilisez le CACHE clauses to indicate how Oracle Database should store blocks in the buffer cache. If you specify neither CACHE nor NOCACHE, then:

  • Dans un CREATE TABLE statement, NOCACHE is the default

  • Dans un MODIFIER TABLE statement, the existing value is not changed.

CACHE For data that is accessed frequently, this clause indicates that the blocks retrieved for this table are placed at the most recently used end of the least recently used (LRU) list in the buffer cache when a full table scan is performed. This attribute is useful for small lookup tables.

As a parameter in the LOB_storage_clause, CACHE specifies that the database places LOB data values in the buffer cache for faster access.

Restriction on CACHE You cannot specify CACHE for an index-organized table. However, index-organized tables implicitly provide CACHE behavior.

NOCACHE For data that is not accessed frequently, this clause indicates that the blocks retrieved for this table are placed at the least recently used end of the LRU list in the buffer cache when a full table scan is performed. NOCACHE is the default for LOB storage.

As a parameter in the LOB_storage_clause, NOCACHE specifies that the LOB value either is not brought into the buffer cache or is brought into the buffer cache and placed at the least recently used end of the LRU list. The latter is the default behavior.

Restriction on NOCACHE You cannot specify NOCACHE for an index-organized table.

CACHE READS CACHE READS applies only to LOB storage. It specifies that LOB values are brought into the buffer cache only during read operations but not during write operations.

Voir également:

logging_clause for a description of the logging_clause when specified as part of LOB_parameters

parallel_clause

le parallel_clause lets you parallelize creation of the table and set the default degree of parallelism for queries and the DML INSÉRER, UPDATE, DELETE, et MERGE after table creation.

Remarque:

The syntax of the parallel_clause supersedes syntax appearing in earlier releases of Oracle. Superseded syntax is still supported for backward compatibility but may result in slightly different behavior from that documented.

NOPARALLEL Specify NOPARALLEL for serial execution. This is the default.

PARALLEL Specify PARALLEL if you want Oracle to select a degree of parallelism equal to the number of CPUs available on all participating instances times the value of the PARALLEL_THREADS_PER_CPU initialization parameter.

PARALLEL entier Specification of entier indicates the degree of parallelism, which is the number of parallel threads used in the parallel operation. Each parallel thread may use one or two parallel execution servers. Normally Oracle calculates the optimum degree of parallelism, so it is not necessary for you to specify entier.

NOROWDEPENDENCIES | ROWDEPENDENCIES

This clause lets you specify whether table will use row-level dependency tracking. With this feature, each row in the table has a system change number (SCN) that represents a time greater than or equal to the commit time of the last transaction that modified the row. You cannot change this setting after table is created.

ROWDEPENDENCIES Specify ROWDEPENDENCIES if you want to enable row-level dependency tracking. This setting is useful primarily to allow for parallel propagation in replication environments. It increases the size of each row by 6 bytes.

NOROWDEPENDENCIES Specify NOROWDEPENDENCIES if you do not want table to use the row-level dependency tracking feature. This is the default.

MONITORING | NOMONITORING

In earlier releases, you could use these clauses to start or stop the collection of modification statistics on this table. These clauses have been deprecated.

  • If you formerly collected modification statistics on tables by using the DBMS_STATS package in GATHER AUTO ou GATHER STALE mode, then you no longer have to do anything. Oracle Database now collects these statistics automatically, and the MONITORING et NOMONITORING keywords in existing code will not cause an error.

  • If, for performance reasons, you do not want to collect modification statistics on any tables, then you should set the STATISTICS_LEVEL initialization parameter to BASIC. Be aware, however, that doing so disables a number of manageability features.

Voir également:

Oracle Database Reference for information on the STATISTICS_LEVEL initialization parameter, including its affect on Oracle Database manageability features

enable_disable_clause

le enable_disable_clause lets you specify whether Oracle Database should apply a constraint. By default, constraints are created in ENABLE VALIDATE Etat.

Restrictions on Enabling and Disabling Constraints Enabling and disabling constraints are subject to the following restrictions:

  • To enable or disable any integrity constraint, you must have defined the constraint in this or a previous statement.

  • You cannot enable a foreign key constraint unless the referenced unique or primary key constraint is already enabled.

ENABLE Clause Use this clause if you want the constraint to be applied to the data in the table. This clause is described fully in "ENABLE Clause" in the documentation on constraints.

DISABLE Clause Use this clause if you want to disable the integrity constraint. This clause is described fully in "DISABLE Clause" in the documentation on constraints.

UNIQUE le UNIQUE clause lets you enable or disable the unique constraint defined on the specified column or combination of columns.

PRIMARY KEY le PRIMARY KEY clause lets you enable or disable the primary key constraint defined on the table.

CONSTRAINT le CONSTRAINT clause lets you enable or disable the integrity constraint named constraint.

KEEP | DROP INDEX This clause lets you either preserve or drop the index Oracle Database has been using to enforce a unique or primary key constraint.

Restriction on Preserving and Dropping Indexes You can specify this clause only when disabling a unique or primary key constraint.

using_index_clause le using_index_clause lets you specify an index for Oracle Database to use to enforce a unique or primary key constraint, or lets you instruct the database to create the index used to enforce the constraint. This clause is discussed fully in using_index_clause in the documentation on constraints.

CASCADE Specify CASCADE to disable any integrity constraints that depend on the specified integrity constraint. To disable a primary or unique key that is part of a referential integrity constraint, you must specify this clause.

Restriction on CASCADE You can specify CASCADE only if you have specified DISABLE.

row_movement_clause

le row_movement_clause lets you specify whether the database can move a table row. It is possible for a row to move, for example, during table compression or an update operation on partitioned data.

Caution:

If you need static rowids for data access, do not enable row movement. For a normal (heap-organized) table, moving a row changes the rowid of the row. For a moved row in an index-organized table, the logical rowid remains valid, although the physical guess component of the logical rowid becomes inaccurate.

  • Specify ENABLE to allow the database to move a row, thus changing the rowid.

  • Specify DISABLE if you want to prevent the database from moving a row, thus preventing a change of rowid.

If you omit this clause, then the database disables row movement.

Restriction on Row Movement You cannot specify this clause for a nonpartitioned index-organized table.

COMME subquery

Specify a subquery to determine the contents of the table. The rows returned by the subquery are inserted into the table upon its creation.

For object tables, subquery can contain either one expression corresponding to the table type, or the number of top-level attributes of the table type. Please refer to SELECT for more information.

Si subquery returns the equivalent of part or all of an existing materialized view, then the database may rewrite the query to use the materialized view in place of one or more tables specified in subquery.

Oracle Database derives datatypes and lengths from the subquery. Oracle Database follows the following rules for integrity constraints and other column and table attributes:

  • Oracle Database automatically defines on columns in the new table any NE PAS NULL constraints that were explicitly created on the corresponding columns of the selected table if the subquery selects the column rather than an expression containing the column. If any rows violate the constraint, then the database does not create the table and returns an error.

  • NE PAS NULL constraints that were implicitly created by Oracle Database on columns of the selected table (for example, for primary keys) are not carried over to the new table.

  • In addition, primary keys, unique keys, foreign keys, check constraints, partitioning criteria, indexes, and column default values are not carried over to the new table.

  • If the selected table is partitioned, you can choose whether the new table will be partitioned the same way, partitioned differently, or not partitioned. Partitioning is not carried over to the new table. Specify any desired partitioning as part of the CREATE TABLE statement before the COMME subquery clause.

If all expressions in subquery are columns, rather than expressions, then you can omit the columns from the table definition entirely. In this case, the names of the columns of table are the same as the columns in subquery.

You can use subquery in combination with the TO_LOB function to convert the values in a LONG column in another table to LOB values in a column of the table you are creating.

parallel_clause If you specify the parallel_clause in this statement, then the database will ignore any value you specify for the INITIAL storage parameter and will instead use the value of the NEXT parameter.

ORDER BY le ORDER PAR clause lets you order rows returned by the subquery.

When specified with CREATE TABLE, this clause does not necessarily order data across the entire table. For example, it does not order across partitions. Specify this clause if you intend to create an index on the same key as the ORDER PAR key column. Oracle Database will cluster data on the ORDER PAR key so that it corresponds to the index key.

Restrictions on the Defining Query of a Table The table query is subject to the following restrictions:

  • The number of columns in the table must equal the number of expressions in the subquery.

  • The column definitions can specify only column names, default values, and integrity constraints, not datatypes.

  • You cannot define a foreign key constraint in a CREATE TABLE statement that contains COMME subquery. Instead, you must create the table without the constraint and then add it later with an MODIFIER TABLE déclaration.

object_table

le OF clause lets you explicitly create an object table of type object_type. The columns of an object table correspond to the top-level attributes of type object_type. Each row will contain an object instance, and each instance will be assigned a unique, system-generated object identifier when a row is inserted. If you omit schema, then the database creates the object table in your own schema.

Object tables, as well as XMLType tables, object views, and XMLType views, do not have any column names specified for them. Therefore, Oracle defines a system-generated pseudocolumn OBJECT_ID. You can use this column name in queries and to create object views with the AVEC OBJECT IDENTIFIER clause.

object_table_substitution

Utilisez le object_table_substitution clause to specify whether row objects corresponding to subtypes can be inserted into this object table.

NOT SUBSTITUTABLE AT ALL LEVELS NE PAS SUBSTITUTABLE À TOUT LEVELS indicates that the object table being created is not substitutable. In addition, substitution is disabled for all embedded object attributes and elements of embedded nested tables and arrays. The default is SUBSTITUTABLE À TOUT LEVELS.

object_properties

The properties of object tables are essentially the same as those of relational tables. However, instead of specifying columns, you specify attributes of the object.

Pour attribute, specify the qualified column name of an item in an object.

oid_clause

le oid_clause lets you specify whether the object identifier of the object table should be system generated or should be based on the primary key of the table. The default is SYSTEM GENERATED.

Restrictions on the oid_clause This clause is subject to the following restrictions:

  • You cannot specify OBJECT IDENTIFIER IS PRIMARY KEY unless you have already specified a PRIMARY KEY constraint for the table.

  • You cannot specify this clause for a nested table.

Remarque:

A primary key object identifier is locally unique but not necessarily globally unique. If you require a globally unique identifier, then you must ensure that the primary key is globally unique.

oid_index_clause

This clause is relevant only if you have specified the oid_clause comme SYSTEM GENERATED. It specifies an index, and optionally its storage characteristics, on the hidden object identifier column.

Pour indice, specify the name of the index on the hidden system-generated object identifier column. If you omit indice, then the database generates a name.

physical_properties et table_properties

The semantics of these clauses are documented in the corresponding sections under relational tables. See physical_properties et table_properties.

XMLType_table

Utilisez le XMLType_table syntax to create a table of datatype XMLType. Most of the clauses used to create an XMLType table have the same semantics that exist for object tables. The clauses specific to XMLType tables are described in this section.

Object tables, as well as XMLType tables, object views, and XMLType views, do not have any column names specified for them. Therefore, Oracle defines a system-generated pseudocolumn OBJECT_ID. You can use this column name in queries and to create object views with the AVEC OBJECT IDENTIFIER clause.

XMLType_storage

This clause lets you determine how Oracle Database manages the storage of the underlying columns.

OBJECT RELATIONAL Specify OBJECT RELATIONAL if you want the database to store the XMLType data in object relational columns. If you specify OBJECT RELATIONAL, then you must also specify an XMLSchema in the XMLSchema_storage_clause, and you must already have registered the schema using the DBMS_XMLSCHEMA package. Oracle Database will create the table conforming to the registered schema.

CLOB Specify CLOB if you want the database to store the XML data in a CLOB column. If you specify CLOB, then you may also specify either a LOB segment name, or the LOB_parameters clause, or both.

XMLSchema_spec

This clause lets you specify the URL of a registered XMLSchema, either in the XMLSCHEMA clause or as part of the ÉLÉMENT clause, and an XML element name. You must specify an element, although the XMLSchema URL is optional. If you do specify an XMLSchema URL, then you must already have registered the XMLSchema using the DBMS_XMLSCHEMA package.

Exemples

General Examples

This statement shows how the employees table owned by the sample human resources (hr) schema was created. A hypothetical name is given to the table and constraints so that you can duplicate this example in your test database:



CREATE TABLE employees_demo
    ( employee_id    NUMBER(6)
    , first_name     VARCHAR2(20)
    , last_name      VARCHAR2(25) 
         CONSTRAINT emp_last_name_nn_demo NOT NULL
    , email          VARCHAR2(25) 
         CONSTRAINT emp_email_nn_demo     NOT NULL
    , phone_number   VARCHAR2(20)
    , hire_date      DATE  DEFAULT SYSDATE 
         CONSTRAINT emp_hire_date_nn_demo  NOT NULL
    , job_id         VARCHAR2(10)
       CONSTRAINT     emp_job_nn_demo  NOT NULL
    , salary         NUMBER(8,2)
       CONSTRAINT     emp_salary_nn_demo  NOT NULL
    , commission_pct NUMBER(2,2)
    , manager_id     NUMBER(6)
    , department_id  NUMBER(4)
    , dn             VARCHAR2(300)
    , CONSTRAINT     emp_salary_min_demo
                     CHECK (salary > 0) 
    , CONSTRAINT     emp_email_uk_demo
                     UNIQUE (email)
    ) ;

This table contains twelve columns. le employee_id column is of datatype NUMBER. le hire_date column is of datatype DATE and has a default value of SYSDATE. le last_name column is of type VARCHAR2 and has a NE PAS NULL constraint, and so on.

Storage Example To define the same employees_demo table in the example tablespace with a small storage capacity and limited allocation potential, issue the following statement:



CREATE TABLE employees_demo
    ( employee_id    NUMBER(6)
    , first_name     VARCHAR2(20)
    , last_name      VARCHAR2(25) 
         CONSTRAINT emp_last_name_nn_demo NOT NULL
    , email          VARCHAR2(25) 
         CONSTRAINT emp_email_nn_demo     NOT NULL
    , phone_number   VARCHAR2(20)
    , hire_date      DATE  DEFAULT SYSDATE 
         CONSTRAINT emp_hire_date_nn_demo  NOT NULL
    , job_id         VARCHAR2(10)
       CONSTRAINT     emp_job_nn_demo  NOT NULL
    , salary         NUMBER(8,2)
       CONSTRAINT     emp_salary_nn_demo  NOT NULL
    , commission_pct NUMBER(2,2)
    , manager_id     NUMBER(6)
    , department_id  NUMBER(4)
    , dn             VARCHAR2(300)
    , CONSTRAINT     emp_salary_min_demo
                     CHECK (salary > 0) 
    , CONSTRAINT     emp_email_uk_demo
                     UNIQUE (email)
    )
   TABLESPACE example 
   STORAGE (INITIAL     6144  
            NEXT        6144 
            MINEXTENTS     1  
            MAXEXTENTS     5 ); 

Temporary Table Example The following statement creates a temporary table today_sales for use by sales representatives in the sample database. Each sales representative session can store its own sales data for the day in the table. The temporary data is deleted at the end of the session.



CREATE GLOBAL TEMPORARY TABLE today_sales
   ON COMMIT PRESERVE ROWS 
   AS SELECT * FROM orders WHERE order_date = SYSDATE;

Substitutable Table and Column Examples The following statement creates a substitutable table from the person_t type, which was created in "Type Hierarchy Example":



CREATE TABLE persons OF person_t;

The following statement creates a table with a substitutable column of type person_t:



CREATE TABLE books (title VARCHAR2(100), author person_t);

When you insert into persons ou books, you can specify values for the attributes of person_t or any of its subtypes. Examples of insert statements appear in "Inserting into a Substitutable Tables and Columns: Examples".

You can extract data from such tables using built-in functions and conditions. For examples, see the functions TREAT and SYS_TYPEID, and the "IS OF type Condition" condition.

PARALLEL Example The following statement creates a table using an optimum number of parallel execution servers to scan employees and to populate dept_80:



CREATE TABLE dept_80
   PARALLEL
   AS SELECT * FROM employees
   WHERE department_id = 80;

Using parallelism speeds up the creation of the table, because the database uses parallel execution servers to create the table. After the table is created, querying the table is also faster, because the same degree of parallelism is used to access the table.

NOPARALLEL Example The following statement creates the same table serially. Subsequent DML and queries on the table will also be serially executed.



CREATE TABLE dept_80
   AS SELECT * FROM employees
   WHERE department_id = 80;

ENABLE VALIDATE Example The following statement shows how the sample table departments was created. The example defines a NE PAS NULL constraint, and places it in ENABLE VALIDATE Etat. A hypothetical name is given to the table so that you can duplicate this example in your test database:



CREATE TABLE departments_demo
    ( department_id    NUMBER(4)
    , department_name  VARCHAR2(30)
           CONSTRAINT  dept_name_nn  NOT NULL
    , manager_id       NUMBER(6)
    , location_id      NUMBER(4)
    , dn               VARCHAR2(300)
    ) ;

DISABLE Example The following statement creates the same departments_demo table but also defines a disabled primary key constraint:



CREATE TABLE departments_demo
    ( department_id    NUMBER(4)   PRIMARY KEY DISABLE
    , department_name  VARCHAR2(30)
           CONSTRAINT  dept_name_nn  NOT NULL
    , manager_id       NUMBER(6)
    , location_id      NUMBER(4)
    , dn               VARCHAR2(300)
    ) ;

Nested Table Example The following statement shows how the sample table pm.print_media was created with a nested table column ad_textdocs_ntab:



CREATE TABLE print_media
    ( product_id        NUMBER(6)
    , ad_id             NUMBER(6)
    , ad_composite      BLOB
    , ad_sourcetext     CLOB
    , ad_finaltext      CLOB
    , ad_fltextn        NCLOB
    , ad_textdocs_ntab  textdoc_tab
    , ad_photo          BLOB
    , ad_graphic        BFILE
    , ad_header         adheader_typ
    ) NESTED TABLE ad_textdocs_ntab STORE AS textdocs_nestedtab;

Multi-level Collection Example The following example shows how an account manager might create a table of customers using two levels of nested tables:



CREATE TYPE phone AS OBJECT (telephone NUMBER);
/
CREATE TYPE phone_list AS TABLE OF phone;
/
CREATE TYPE my_customers AS OBJECT (
   cust_name VARCHAR2(25),
   phones phone_list);
/
CREATE TYPE customer_list AS TABLE OF my_customers;
/
CREATE TABLE business_contacts (
   company_name VARCHAR2(25),
   company_reps customer_list)
   NESTED TABLE company_reps STORE AS outer_ntab
   (NESTED TABLE phones STORE AS inner_ntab);

The following variation of this example shows how to use the COLUMN_VALUE keyword if the inner nested table has no column or attribute name:



CREATE TYPE phone AS TABLE OF NUMBER;    
/
CREATE TYPE phone_list AS TABLE OF phone;
/
CREATE TABLE my_customers (
   name VARCHAR2(25),
   phone_numbers phone_list)
   NESTED TABLE phone_numbers STORE AS outer_ntab
   (NESTED TABLE COLUMN_VALUE STORE AS inner_ntab);

LOB Column Example The following statement is a variation of the statement that created the pm.print_media table with some added LOB storage characteristics:



CREATE TABLE print_media_new
    ( product_id        NUMBER(6)
    , ad_id             NUMBER(6)
    , ad_composite      BLOB
    , ad_sourcetext     CLOB
    , ad_finaltext      CLOB
    , ad_fltextn        NCLOB
    , ad_textdocs_ntab  textdoc_tab
    , ad_photo          BLOB
    , ad_graphic        BFILE
    , ad_header         adheader_typ
    , press_release     LONG
    ) NESTED TABLE ad_textdocs_ntab STORE AS textdocs_nestedtab_new
    LOB (ad_sourcetext, ad_finaltext) STORE AS
      (TABLESPACE example
       STORAGE (INITIAL 6144 NEXT 6144)
       CHUNK 4000
       NOCACHE LOGGING);

In the example, the database rounds the value of CHUNK up to 4096 (the nearest multiple of the block size of 2048).

Index-Organized Table Example The following statement is a variation of the sample table hr.countries, which is index organized:



CREATE TABLE countries_demo
    ( country_id      CHAR(2)
      CONSTRAINT country_id_nn_demo NOT NULL
    , country_name    VARCHAR2(40)
    , currency_name   VARCHAR2(25)
    , currency_symbol VARCHAR2(3)
    , region          VARCHAR2(15)
    , CONSTRAINT    country_c_id_pk_demo
                    PRIMARY KEY (country_id ) )
    ORGANIZATION INDEX 
    INCLUDING   country_name 
    PCTTHRESHOLD 2 
    ESPACE DE RANGEMENT
     ( INITIAL  4K 
      NEXT  2K 
      PCTINCREASE 0 
      MINEXTENTS 1 
      MAXEXTENTS 1 ) 
   OVERFLOW 
    ESPACE DE RANGEMENT
      ( INITIAL  4K 
        NEXT  2K 
        PCTINCREASE 0 
        MINEXTENTS 1 
        MAXEXTENTS 1 ); 

External Table Example The following statement creates an external table that represents a subset of the sample table hr.departments. le opaque_format_spec is shown in italics. Please refer to Oracle Database Utilities for information on the ORACLE_LOADER access driver and how to specify values for the opaque_format_spec.



CREATE TABLE dept_external (
   deptno     NUMBER(6),
   dname      VARCHAR2(20),
   loc        VARCHAR2(25) 
)
ORGANIZATION EXTERNAL
(TYPE oracle_loader
 DEFAULT DIRECTORY admin
 ACCESS PARAMETERS
 (
  RECORDS DELIMITED BY newline
        BADFILE 'ulcase1.bad'
        DISCARDFILE 'ulcase1.dis'
        LOGFILE 'ulcase1.log'
        SKIP 20
        FIELDS TERMINATED BY ","  OPTIONALLY ENCLOSED BY '"'
        (
            deptno     INTEGER EXTERNAL(6),
            dname      CHAR(20),
            loc        CHAR(25)
  )
 )
 LOCATION ('ulcase1.ctl')
)
REJECT LIMIT UNLIMITED;

XMLType Examples

This section contains brief examples of creating an XMLType table or XMLType column. For a more expanded version of these examples, please refer to "Using XML in SQL Statements".

XMLType Table Examples The following example creates a very simple XMLType table with one implicit CLOB column:



CREATE TABLE xwarehouses OF XMLTYPE;

Because Oracle Database implicitly stores the data in a CLOB column, it is subject to all of the restrictions on LOB columns. To avoid these restrictions, you can create an XMLSchema-based table, as shown in the following example. The XMLSchema must already have been created (see "Using XML in SQL Statements" for more information):



CREATE TABLE xwarehouses OF XMLTYPE
   XMLSCHEMA "http://www.oracle.com/xwarehouses.xsd"
   ELEMENT "Warehouse";

You can define constraints on an XMLSchema-based table, and you can also create indexes on XMLSchema-based tables, which greatly enhance subsequent queries. You can create object-relational views on XMLType tables, and you can create XMLType views on object-relational tables.

XMLType Column Examples The following example creates a table with an XMLType column stored as a CLOB. This table does not require an XMLSchema, so the content structure is not predetermined:



CREATE TABLE xwarehouses (
   warehouse_id        NUMBER,
   warehouse_spec      XMLTYPE)
   XMLTYPE warehouse_spec STORE AS CLOB
   (TABLESPACE example
    STORAGE (INITIAL 6144 NEXT 6144)
    CHUNK 4000
    NOCACHE LOGGING);

The following example creates a similar table, but stores XMLType data in an object relational XMLType column whose structure is determined by the specified schema:



CREATE TABLE xwarehouses (
   warehouse_id    NUMBER,
   warehouse_spec  XMLTYPE)
   XMLTYPE warehouse_spec STORE AS OBJECT RELATIONAL
      XMLSCHEMA "http://www.oracle.com/xwarehouses.xsd"
      ELEMENT "Warehouse";

Partitioning Examples

Range Partitioning Example le Ventes table in the sample schema sh is partitioned by range. The following example shows an abbreviated variation of the Ventes table. Constraints and storage elements have been omitted from the example.



CREATE TABLE range_sales
    ( prod_id        NUMBER(6)
    , cust_id        NUMBER
    , time_id        DATE
    , channel_id     CHAR(1)
    , promo_id       NUMBER(6)
    , quantity_sold  NUMBER(3)
    , amount_sold         NUMBER(10,2)
    )
PARTITION BY RANGE (time_id)
  (PARTITION SALES_Q1_1998 VALUES LESS THAN (TO_DATE('01-APR-1998','DD-MON-YYYY')),
   PARTITION SALES_Q2_1998 VALUES LESS THAN (TO_DATE('01-JUL-1998','DD-MON-YYYY')),
   PARTITION SALES_Q3_1998 VALUES LESS THAN (TO_DATE('01-OCT-1998','DD-MON-YYYY')),
   PARTITION SALES_Q4_1998 VALUES LESS THAN (TO_DATE('01-JAN-1999','DD-MON-YYYY')),
   PARTITION SALES_Q1_1999 VALUES LESS THAN (TO_DATE('01-APR-1999','DD-MON-YYYY')),
   PARTITION SALES_Q2_1999 VALUES LESS THAN (TO_DATE('01-JUL-1999','DD-MON-YYYY')),
   PARTITION SALES_Q3_1999 VALUES LESS THAN (TO_DATE('01-OCT-1999','DD-MON-YYYY')),
   PARTITION SALES_Q4_1999 VALUES LESS THAN (TO_DATE('01-JAN-2000','DD-MON-YYYY')),
   PARTITION SALES_Q1_2000 VALUES LESS THAN (TO_DATE('01-APR-2000','DD-MON-YYYY')),
   PARTITION SALES_Q2_2000 VALUES LESS THAN (TO_DATE('01-JUL-2000','DD-MON-YYYY')),
   PARTITION SALES_Q3_2000 VALUES LESS THAN (TO_DATE('01-OCT-2000','DD-MON-YYYY')),
   PARTITION SALES_Q4_2000 VALUES LESS THAN (MAXVALUE))
;

For information about partitioned table maintenance operations, see Oracle Database Administrator's Guide.

List Partitioning Example The following statement shows how the sample table oe.customers might have been created as a list-partitioned table. Some columns and all constraints of the sample table have been omitted in this example.



CREATE TABLE list_customers 
   ( customer_id             NUMBER(6)
   , cust_first_name         VARCHAR2(20) 
   , cust_last_name          VARCHAR2(20)
   , cust_address            CUST_ADDRESS_TYP
   , nls_territory           VARCHAR2(30)
   , cust_email              VARCHAR2(30))
   PARTITION BY LIST (nls_territory) (
   PARTITION asia VALUES ('CHINA', 'THAILAND'),
   PARTITION europe VALUES ('GERMANY', 'ITALY', 'SWITZERLAND'),
   PARTITION west VALUES ('AMERICA'),
   PARTITION east VALUES ('INDIA'),
   PARTITION rest VALUES (DEFAULT));

Partitioned Table with LOB Columns Example This statement creates a partitioned table print_media_demo with two partitions p1 et p2, and a number of LOB columns. The statement uses the sample table pm.print_media, but the LONG colonne press_release is omitted because LONG columns are not supported in partitioning.



CREATE TABLE print_media_demo
   ( product_id NUMBER(6)
   , ad_id NUMBER(6)
   , ad_composite BLOB
   , ad_sourcetext CLOB
   , ad_finaltext CLOB
   , ad_fltextn NCLOB
   , ad_textdocs_ntab textdoc_tab
   , ad_photo BLOB
   , ad_graphic BFILE
   , ad_header adheader_typ
   ) NESTED TABLE ad_textdocs_ntab STORE AS textdocs_nestedtab_demo
      LOB (ad_composite, ad_photo, ad_finaltext)
      STORE AS(STORAGE (NEXT 20M))
   PARTITION BY RANGE (product_id)
      (PARTITION p1 VALUES LESS THAN (3000) TABLESPACE tbs_01
         LOB (ad_composite, ad_photo)
         STORE AS (TABLESPACE tbs_02 STORAGE (INITIAL 10M)),
       PARTITION P2 VALUES LESS THAN (MAXVALUE)
         LOB (ad_composite, ad_finaltext)
         STORE AS (TABLESPACE tbs_03)
       )
   TABLESPACE tbs_04;

Partition p1 will be in tablespace tbs_1. The LOB data partitions for ad_composite et ad_photo will be in tablespace tbs_2. The LOB data partition for the remaining LOB columns will be in tablespace tbs_1. The storage attribute INITIAL is specified for LOB columns ad_composite et ad_photo. Other attributes will be inherited from the default table-level specification. The default LOB storage attributes not specified at the table level will be inherited from the tablespace tbs_2 for columns ad_composite et ad_photo and from tablespace tbs_1 for the remaining LOB columns. LOB index partitions will be in the same tablespaces as the corresponding LOB data partitions. Other storage attributes will be based on values of the corresponding attributes of the LOB data partitions and default attributes of the tablespace where the index partitions reside.

Partition p2 will be in the default tablespace tbs_4. The LOB data for ad_composite et ad_finaltext will be in tablespace tbs_3. The LOB data for the remaining LOB columns will be in tablespace tbs_4. The LOB index for columns ad_composite et ad_finaltext will be in tablespace tbs_3. The LOB index for the remaining LOB columns will be in tablespace tbs_4.

Hash Partitioning Example The sample table oe.product_information is not partitioned. However, you might want to partition such a large table by hash for performance reasons, as shown in this example. The tablespace names are hypothetical in this example.



CREATE TABLE hash_products 
    ( product_id          NUMBER(6) 
    , product_name        VARCHAR2(50) 
    , product_description VARCHAR2(2000) 
    , category_id         NUMBER(2) 
    , weight_class        NUMBER(1) 
    , warranty_period     INTERVAL YEAR TO MONTH 
    , supplier_id         NUMBER(6) 
    , product_status      VARCHAR2(20) 
    , list_price          NUMBER(8,2) 
    , min_price           NUMBER(8,2) 
    , catalog_url         VARCHAR2(50) 
    , CONSTRAINT          product_status_lov_demo 
                          CHECK (product_status in ('orderable' 
                                                  ,'planned' 
                                                  ,'under development' 
                                                  ,'obsolete') 
 ) ) 
 PARTITION BY HASH (product_id) 
 PARTITIONS 5 
 STORE IN (tbs_01, tbs_02, tbs_03, tbs_04); 

Composite-Partitioned Table Examples The table created in the "Range Partitioning Example" divides data by time of sale. If you plan to access recent data according to distribution channel as well as time, then composite partitioning might be more appropriate. The following example creates a copy of that range_sales table but specifies range-hash composite partitioning. The partitions with the most recent data are subpartitioned with both system-generated and user-defined subpartition names. Constraints and storage attributes have been omitted from the example.



CREATE TABLE composite_sales
    ( prod_id        NUMBER(6)
    , cust_id        NUMBER
    , time_id        DATE
    , channel_id     CHAR(1)
    , promo_id       NUMBER(6)
    , quantity_sold  NUMBER(3)
    , amount_sold         NUMBER(10,2)
    )
PARTITION BY RANGE (time_id)
SUBPARTITION BY HASH (channel_id)
  (PARTITION SALES_Q1_1998 VALUES LESS THAN (TO_DATE('01-APR-1998','DD-MON-YYYY')),
   PARTITION SALES_Q2_1998 VALUES LESS THAN (TO_DATE('01-JUL-1998','DD-MON-YYYY')),
   PARTITION SALES_Q3_1998 VALUES LESS THAN (TO_DATE('01-OCT-1998','DD-MON-YYYY')),
   PARTITION SALES_Q4_1998 VALUES LESS THAN (TO_DATE('01-JAN-1999','DD-MON-YYYY')),
   PARTITION SALES_Q1_1999 VALUES LESS THAN (TO_DATE('01-APR-1999','DD-MON-YYYY')),
   PARTITION SALES_Q2_1999 VALUES LESS THAN (TO_DATE('01-JUL-1999','DD-MON-YYYY')),
   PARTITION SALES_Q3_1999 VALUES LESS THAN (TO_DATE('01-OCT-1999','DD-MON-YYYY')),
   PARTITION SALES_Q4_1999 VALUES LESS THAN (TO_DATE('01-JAN-2000','DD-MON-YYYY')),
   PARTITION SALES_Q1_2000 VALUES LESS THAN (TO_DATE('01-APR-2000','DD-MON-YYYY')),
   PARTITION SALES_Q2_2000 VALUES LESS THAN (TO_DATE('01-JUL-2000','DD-MON-YYYY'))
      SUBPARTITIONS 8,
   PARTITION SALES_Q3_2000 VALUES LESS THAN (TO_DATE('01-OCT-2000','DD-MON-YYYY'))
     (SUBPARTITION ch_c,
      SUBPARTITION ch_i,
      SUBPARTITION ch_p,
      SUBPARTITION ch_s,
      SUBPARTITION ch_t),
   PARTITION SALES_Q4_2000 VALUES LESS THAN (MAXVALUE)
      SUBPARTITIONS 4)
;

The following examples creates a partitioned table of customers based on the sample table oe.customers. In this example, the table is partitioned on the credit_limit column and list subpartitioned on the nls_territory column. The subpartition template determines the subpartitioning of any subsequently added partitions, unless you override the template by defining individual subpartitions. This composite partitioning makes it possible to query the table based on a credit limit range within a specified region:



CREATE TABLE customers_part (
   customer_id        NUMBER(6),
   cust_first_name    VARCHAR2(20),
   cust_last_name     VARCHAR2(20),
   nls_territory      VARCHAR2(30),
   credit_limit       NUMBER(9,2)) 
   PARTITION BY RANGE (credit_limit)
   SUBPARTITION BY LIST (nls_territory)
      SUBPARTITION TEMPLATE 
         (SUBPARTITION east  VALUES 
            ('CHINA', 'JAPAN', 'INDIA', 'THAILAND'),
          SUBPARTITION west VALUES 
             ('AMERICA', 'GERMANY', 'ITALY', 'SWITZERLAND'),
          SUBPARTITION other VALUES (DEFAULT))
      (PARTITION p1 VALUES LESS THAN (1000),
       PARTITION p2 VALUES LESS THAN (2500),
       PARTITION p3 VALUES LESS THAN (MAXVALUE));

Object Column and Table Examples

Creating Object Tables: Examples Consider object type department_typ:



CREATE TYPE department_typ AS OBJECT
   ( d_name   VARCHAR2(100), 
     d_address VARCHAR2(200) );
/
 

Object table departments_obj_t holds department objects of type department_typ:



CREATE TABLE departments_obj_t OF department_typ; 

The following statement creates object table salesreps with a user-defined object type, salesrep_typ:



CREATE OR REPLACE TYPE salesrep_typ AS OBJECT
  ( repId NUMBER,
    repName VARCHAR2(64));

CREATE TABLE salesreps OF salesrep_typ;

Creating a Table with a User-Defined Object Identifier: Example This example creates an object type and a corresponding object table whose object identifier is primary key based:



CREATE TYPE employees_typ AS OBJECT 
   (e_no NUMBER, e_address CHAR(30));
/

CREATE TABLE employees_obj_t OF employees_typ (e_no PRIMARY KEY)
   OBJECT IDENTIFIER IS PRIMARY KEY;

You can subsequently reference the employees_object_t object table using either inline_ref_constraint ou out_of_line_ref_constraint syntax



CREATE TABLE departments_t 
   (d_no    NUMBER,
    mgr_ref REF employees_typ SCOPE IS employees_obj_t);

CREATE TABLE departments_t (
    d_no NUMBER,
    mgr_ref REF employees_typ 
       CONSTRAINT mgr_in_emp REFERENCES employees_obj_t);

Specifying Constraints on Type Columns: Example The following example shows how to define constraints on attributes of an object type column:



CREATE TYPE address_t AS OBJECT
  ( hno    NUMBER,
    street VARCHAR2(40),
    city   VARCHAR2(20),
    zip    VARCHAR2(5),
    phone  VARCHAR2(10) );
/

CREATE TYPE person AS OBJECT
  ( name        VARCHAR2(40),
    dateofbirth DATE,
    homeaddress address_t,
    manager     REF person );
/

CREATE TABLE persons OF person
  ( homeaddress NOT NULL,
      UNIQUE (homeaddress.phone),
      CHECK (homeaddress.zip IS NOT NULL),
      CHECK (homeaddress.city <> 'San Francisco') );

Commentaires

Laisser un commentaire

Votre commentaire sera révisé par les administrateurs si besoin.