isql命令只要用户操作数据库,链接,创建,增删改查等!
1. 管理员登陆,并通过ip链接到数据库(默认密码是masterkey,由于在上一篇文章中把密码改成了1723,所以这里用1723登陆)。
C:\Users\Administrator>isql -u sysdba -p 1723;
Use CONNECT or CREATE DATABASE to specify a database
SQL> connect "127.0.0.1:c:\hlp2.fdb";
Database: "127.0.0.1:c:\hlp2.fdb", User: sysdba
SQL>
如果链接到本地数据库,直接把ip地址省掉就可以了。
SQL> connect "c:\hlp2.fdb";
2. 自带的命令帮助
SQL> help;
Frontend commands:
BLOBDUMP <blobid> <file> -- dump BLOB to a file
BLOBVIEW <blobid> -- view BLOB in text editor
EDIT [<filename>] -- edit SQL script file and execute
EDIT -- edit current command buffer and execute
HELP -- display this menu
INput <filename> -- take input from the named SQL file
OUTput [<filename>] -- write output to named file
OUTput -- return output to stdout
SET <option> -- (Use HELP SET for complete list)
SHELL <command> -- execute Operating System command in sub-shell
SHOW <object> [<name>] -- display system information
<object> = CHECK, COLLATION, DATABASE, DOMAIN, EXCEPTION, FILTER, FUNCTION,
GENERATOR, GRANT, INDEX, PROCEDURE, ROLE, SQL DIALECT, SYSTEM,
TABLE, TRIGGER, VERSION, USERS, VIEW
EXIT -- exit and commit changes
QUIT -- exit and roll back changes
All commands may be abbreviated to letters in CAPitals
3. 创建并管理数据库元素(表、视图、触发器、域、索引等)
- 域:其实就是自己重新定义的数据类型,好处是容易阅读和统一修改。例:
- SQL>CREATE DOMAIN EMAIL_ADDRESS AS
CON>VARCHAR(255) CHARACTER SET NONE
COLLATE NONE; - CREATE DOMAIN KEY_ID AS INTEGER NOT NULL;
- CREATE DOMAIN KEY_NAME AS VARCHAR(40) CHARACTER SET NONE COLLATE NONE;
- SQL>CREATE DOMAIN NORM_BLOB AS BLOB SUB_TYPE 0 SEGMENT SIZE 80;
- 显示域:
SQL>SHOW DOMAINS;
EMAIL_ADDRESS KEY_ID
KEY_NAME NORM_BLOB
- SQL>CREATE DOMAIN EMAIL_ADDRESS AS
- 表:用域来创建表比直接用原始数据类型方便以后管理。比如以后“KEY_NAME”这类类型,字串长度改变,只需要改变域“KEY_NAME”的定义,所有表格中用域"KEY_NAME"定义的字段的类型都自动改变了,而不需要一个个去更改。
- SQL>CREATE TABLE YS_STAFF (
CON>STAFFID KEY_ID NOT NULL ,
CON>STAFFNAME KEY_NAME ,
CON>STAFF_OPTION NORM_BLOB
CON>); - 设置表的主键:
SQL>ALTER TABLE YS_STAFF ADD CONSTRAINT PK_YS_STAFF_1 PRIMARY KEY (STAFFID); - 显示表格:
SQL>SHOW TABLES;
YS_STAFF
- SQL>CREATE TABLE YS_STAFF (
- 不一一举例了,具体的可以查看官网上的pdf手册或SQL语言手册。
- OUTPUT <FILENAME>:将输出结果写进指定文件,这是一个很有用的功能。
- edit:默认打开写字板。编辑后保存退出即可执行写字板语句。
- shell:执行os的命令。这样就能在方便编写自动日常处理功能。比如用output filename 产生报表,调用外部程序rar.exe 压缩备份.调用ftp程序分发报表。等等。