,谁说程序员不能有文艺范?


SQL标准里面是有schema的概念的,只是不同的数据库在具体实现的时候出现了差别。在Derby、SQLServer是支持schema的,而Oracle中schema应该对应其实例(orcl),而MySQL中schema应该对应的是其database。

通过create schema lucl;在Derby中创建一个schema,通过DBeaver工具查看:

Derby的系统表位于SYS schema中,但SYS却不是系统默认的schema,因此查询表时需要指定SYS前缀,SYS.TABLE_NAME。Derby的系统表只能查询,无法通过命令修改。

ij> show tables in sys;TABLE_SCHEM         |TABLE_NAME                    |REMARKS------------------------------------------------------------------------SYS                 |SYSALIASES                    |SYS                 |SYSCHECKS                     |SYS                 |SYSCOLPERMS                   |SYS                 |SYSCOLUMNS                    |SYS                 |SYSCONGLOMERATES              |SYS                 |SYSCONSTRAINTS                |SYS                 |SYSDEPENDS                    |SYS                 |SYSFILES                      |SYS                 |SYSFOREIGNKEYS                |SYS                 |SYSKEYS                       |SYS                 |SYSPERMS                      |SYS                 |SYSROLES                      |SYS                 |SYSROUTINEPERMS               |SYS                 |SYSSCHEMAS                    |SYS                 |SYSSEQUENCES                  |SYS                 |SYSSTATEMENTS                 |SYS                 |SYSSTATISTICS                 |SYS                 |SYSTABLEPERMS                 |SYS                 |SYSTABLES                     |SYS                 |SYSTRIGGERS                   |SYS                 |SYSUSERS                      |SYS                 |SYSVIEWS                      |已选择 22 行ij>

The SYSALIASES table describes the procedures, functions, user-defined types, and user-defined aggregates in the database.

The SYSCHECKS table describes the check constraints within the current database.
The SYSCOLPERMS table stores the column permissions that have been granted but not revoked.

The SYSCOLUMNS table describes the columns within all tables in the current database.
The SYSCONGLOMERATES table describes the conglomerates(整体情况) within the current
database. A conglomerate is a unit of storage and is either a table or an index.
The SYSCONSTRAINTS table describes the information common to all types of constraints within the current database (currently, this includes primary key, unique, foreign key, and check constraints).

The SYSDEPENDS table stores the dependency relationships between persistent objects in the database.

The SYSFILES table describes jar files stored in the database.
The SYSFOREIGNKEYS table describes the information specific to foreign key constraints in the current database.
The SYSKEYS table describes the specific information for primary key and unique constraints within the current database.
The SYSPERMS table describes the USAGE permissions for sequence generators, user-defined types, and user-defined aggregates.
The SYSROLES table stores the roles in the database.
The SYSROUTINEPERMS table stores the permissions that have been granted to routines.
The SYSSCHEMAS table describes the schemas within the current database.
The SYSSEQUENCES table describes the sequence generators in the database.
The SYSSTATEMENTS table describes the prepared statements in the database.
The SYSSTATISTICS table describes the statistics within the current database.
The SYSTABLEPERMS table stores the table permissions that have been granted but not revoked.
The SYSTABLES table describes the tables and views within the current database.
The SYSTRIGGERS table describes the database's triggers.
The SYSUSERS table stores user credentials(用户凭证) when NATIVE authentication is enabled.
The SYSVIEWS table describes the view definitions within the current database.

Derby默认提供的存储过程如下

SYSCS_SET_DATABASE_PROPERTYSYSCS_COMPRESS_TABLESYSCS_CHECKPOINT_DATABASESYSCS_FREEZE_DATABASESYSCS_UNFREEZE_DATABASESYSCS_BACKUP_DATABASESYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODESYSCS_DISABLE_LOG_ARCHIVE_MODESYSCS_SET_RUNTIMESTATISTICSSYSCS_SET_STATISTICS_TIMINGSYSCS_EXPORT_TABLESYSCS_EXPORT_QUERYSYSCS_IMPORT_TABLESYSCS_IMPORT_DATASYSCS_BULK_INSERTSYSCS_INPLACE_COMPRESS_TABLESYSCS_BACKUP_DATABASE_NOWAITSYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE_NOWAITSYSCS_EXPORT_TABLE_LOBS_TO_EXTFILESYSCS_EXPORT_QUERY_LOBS_TO_EXTFILESYSCS_IMPORT_TABLE_LOBS_FROM_EXTFILESYSCS_IMPORT_DATA_LOBS_FROM_EXTFILESYSCS_RELOAD_SECURITY_POLICYSYSCS_SET_USER_ACCESSSYSCS_EMPTY_STATEMENT_CACHESYSCS_UPDATE_STATISTICSSYSCS_SET_XPLAIN_MODESYSCS_SET_XPLAIN_SCHEMASYSCS_CREATE_USERSYSCS_RESET_PASSWORDSYSCS_MODIFY_PASSWORDSYSCS_DROP_USERSYSCS_DROP_STATISTICSSYSCS_INVALIDATE_STORED_STATEMENTSSYSCS_REGISTER_TOOL

内置的系统函数

SYSCS_GET_DATABASE_PROPERTYSYSCS_CHECK_TABLESYSCS_GET_RUNTIMESTATISTICSSYSCS_GET_USER_ACCESSSYSCS_GET_XPLAIN_MODESYSCS_GET_XPLAIN_SCHEMASYSCS_PEEK_AT_SEQUENCESYSCS_PEEK_AT_IDENTITY