FairCom (c-tree) 数据库概要 - 2

c-tree isql是一个交互式SQL工具,支持SQL-92标准,用于学习SQL、测试语句、数据库修改和生成报告。它提供交易处理、系统表和多种功能,如格式化输出和执行脚本。此外,还有dbload和dbdump等其他实用工具,分别用于数据库加载和导出。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

4.              c-tree isql utility

Interactive SQL (often referred to throughout this manual as ISQL) is a utility supplied with ctreeSQL that lets you issue SQL statements directly from a terminal and see results displayed at the terminal. You can use interactive SQL to:

l         Learn how SQL statements work

l         Test and prototype SQL statements to be embedded in programs

l         Modify an existing database with data definition statements

l         Perform ad-hoc queries and generate formatted reports with special ISQL formatting statements

 

4.1.    SQL-92 Standard support

4.1.1.  iSQL supports SQL-92 standard

1)     iSQL command Options:

Graph 4.1.1.1

 

2)     Create a table

Type the following commands to create a table:

CREATE TABLE EMPLOYEE

(

  EMPID        INT,

  FIRSTNAME VARCHAR(30),

  LASTNAME  VARCHAR(30),

  MALE          VARCHAR(10),

  AGE            SMALLINT,

  BIRTH         TIMESTAMP,

  NOTE          VARCHAR(200),

  DEPARTMENTID INT,

  PRIMARY KEY(EMPID)

);

 

CREATE TABLE DEPARTMENT

(

  DEPTID       INT,

  NAME         VARCHAR(50),

  DESCRIPTION    VARCHAR(200),

  PRIMARY KEY(DEPTID)

);

 

3)     Insert records

Type the following commands to insert records to a table:

 

INSERT INTO EMPLOYEE(EMPID, FIRSTNAME, LASTNAME, MALE, AGE, BIRTH, NOTE, DEPARTMENTID) VALUES (1, 'Clark', 'Jin', 'Male', 26, '1999-05-11 13:17:11', '', 1);

INSERT INTO EMPLOYEE(EMPID, FIRSTNAME, LASTNAME, MALE, AGE, BIRTH, NOTE, DEPARTMENTID) VALUES (2, 'Johnson', 'He', 'Male', 28, '1989-05-11 13:17:11', '', 1);

 

INSERT INTO DEPARTMENT VALUES (1, 'STB', 'STB development team');

 

 

4)     Get records

 

Select * from employee;

 

Select (firstname + lastname) as name from employee, department where employee.departmentid = department.deptid;

 

 

5)     Create a index

 

CREATE INDEX IDX_1 ON EMPLOYEE (AGE);

 

 

 

4.1.2.  Transaction Processing

Use command “COMMIT WORK” and “ROLLBACK WORK” to do the transaction processing.

 

4.1.3.  System Tables

c-tree server has many system tables which are similar as SQL Server.

E.g.

l         SysIndexes

l         SysColumns

 

For detail information, please view the iSQL help document.

 

4.1.4.  iSQL statements

iSQL has many other functionalities. E.g.

l         Format outputs

l         Spool outputs to file

l         Execute the script file by “@” statement

 

For detail information, please go to the iSQL help document.

 

5.2.    Other utilities

5.2.1.  dbload utility

The dbload utility allows loading of variable- or fixed-length records, and lets the load operation specify the set of fields and records to be stored from an input file. Data files can use multiple-character record delimiters. dbload also allows control of other characteristics, such as error handling and logging, in its command line. dbload generates a badfile that contains records from the input file that failed to load in the database.

Graph 4.2.1.1

 

 

5.2.2.  dbdump utility

dbdump writes the data in a database to a file. The format of the exported data is specified by

the record description given in an input command file to dbdump.

Graph 4.2.2.1

 

 

5.              c-tree server SQL Reference

Because c-tree server SQL grammar supports SQL-92 standard, most commands are same as standard SQL.

 

5.1.    Data Types

There are several categories of SQL data types:

l         Character

l         Exact numeric

l         Approximate numeric

l         Date-time

l         Bit String

 

All the types can be transferred to SQL Server data types.

 

5.2.    Database objects

There are several categories of c-tree server database objects:

l         Column

l         Index

l         Table

l         View

l         Trigger

l         Stored Procedure

l         Synonym

 

A stored procedure example:

CREATE PROCEDURE new_sal

(

       IN deptnum INTEGER,

       IN pct_incr INTEGER,

)

RESULT

(

       empname CHAR(20),

       oldsal NUMERIC,

       newsal NUMERIC

)

BEGIN

       StringBuffer ename = new StringBuffer (20) ;

       BigDecimal osal = new BigDecimal () ;

       BigDecimal nsal = new BigDecimal () ;

       SQLCursor empcursor = new SQLCursor (

       "SELECT empname, sal, (sal * ( ? /100) + NVL (comm, 0)) total FROM emp WHERE deptnum = ? " ) ;

       empcursor.setParam (1, pct_incr);

       empcursor.setParam (2, deptnum);

       empcursor.open () ;

       do

       {

              empcursor.fetch ();

              if (empcursor.found ())

              {

                     empcursor.getValue (1, ename);

                     empcursor.getValue (2, osal);

                     empcursor.getValue (3, nsal) ;

                     SQLResultSet.set (1, ename);

                     SQLResultSet.set (2, osal);

                     SQLResultSet.set (3, nsal) ;

                     SQLResultSet.insert ();

              }

       } while (empcursor.sound ()) ;

       empcursor.close () ;

END

 

 

5.3.    SQL Functions

 

5.4.    Unicode support

From version 7.11(current Oberon systems use c-tree server 6.10) Unicode was supported by c-tree server.

         For detail information, please view the product documents.

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值