⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e296. creating an object type in an oracle database.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
In Oracle, you can define a composite data structure called an OBJECT, which consists of one or more basic types. For example, you could define an object called book with a title (VARCHAR) and an price (NUMBER). An OBJECT can also contain other OBJECTs. 
This example creates two OBJECT types. object2 contains two fields --- a string and a number while object1 also contains two fields --- a string and a value of type object2. 

The example also creates a table to hold object1 values. See also e297 Inserting an OBJECT Value into an Oracle Table. 

    try {
        // Create a statement
        Statement stmt = connection.createStatement();
    
        // Create the object2 type
        stmt.execute("CREATE TYPE object2 AS OBJECT"
            + "(col_string2 VARCHAR(30), col_integer2 NUMBER)");
    
        // Create the object1 type
        stmt.execute("CREATE TYPE object1 AS OBJECT"
            + "(col_string1 VARCHAR(30), col_integer2 object2)");
    
        // Create a table with a column to hold a number and the new object1 type
        stmt.execute("CREATE TABLE object1_table(col_integer NUMBER, col_object1 object1)");
    } catch (SQLException e) {
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -