SQL Anywhere5.5: Metadata

http://dcx.sybase.com/1101/en/dbprogramming_en11/ianywhere-data-sqlanywhere-saconnection-getschem6330755502-0.html

http://razorsql.com/articles/sybase_admin_queries.html

http://infocenter.sybase.com/help/topic/com.sybase.help.sqlanywhere.11.0.0/pdf/dbadmin_en11.pdf

http://www.mono-project.com/docs/database-access/providers/sybase/

https://github.com/mono/old-code

 https://benohead.com/sybase-create-a-proxy-for-a-remote-database/

http://www.dofactory.com/reference/connection-strings

Columns collection
  • table_schema (Owner)
  • table_name (Table)
  • column_name (Column)
  • ordinal_position
  • column_default
  • is_nullable
  • data_type
  • precision
  • scale
  • column_size
DataSourceInformation collection
  • CompositeIdentifierSeparatorPattern
  • DataSourceProductName
  • DataSourceProductVersion
  • DataSourceProductVersionNormalized
  • GroupByBehavior
  • IdentifierPattern
  • IdentifierCase
  • OrderByColumnsInSelect
  • ParameterMarkerFormat
  • ParameterMarkerPattern
  • ParameterNameMaxLength
  • ParameterNamePattern
  • QuotedIdentifierPattern
  • QuotedIdentifierCase
  • StatementSeparatorPattern
  • StringLiteralPattern
  • SupportedJoinOperators
DataTypes collection
  • TypeName
  • ProviderDbType
  • ColumnSize
  • CreateFormat
  • CreateParameters
  • DataType
  • IsAutoIncrementable
  • IsBestMatch
  • IsCaseSensitive
  • IsFixedLength
  • IsFixedPrecisionScale
  • IsLong
  • IsNullable
  • IsSearchable
  • IsSearchableWithLike
  • IsUnsigned
  • MaximumScale
  • MinimumScale
  • IsConcurrencyType
  • IsLiteralSupported
  • LiteralPrefix
  • LiteralSuffix
ForeignKeys collection
  • table_schema (Owner)
  • table_name (Table)
  • column_name (Column)
IndexColumns collection
  • table_schema (Owner)
  • table_name (Table)
  • index_name (Name)
  • column_name (Column)
  • order
Indexes collection
  • table_schema (Owner)
  • table_name (Table)
  • index_name (Name)
  • primary_key
  • is_unique
MetaDataCollections collection
  • CollectionName
  • NumberOfRestrictions
  • NumberOfIdentifierParts
ProcedureParameters collection
  • procedure_schema (Owner)
  • procedure_name (Name)
  • parmeter_name (Parameter)
  • data_type
  • parameter_type
  • is_input
  • is_output
Procedures collection
  • procedure_schema (Owner)
  • procedure_name (Name)
ReservedWords collection
  • reserved_word
Restrictions collection
  • CollectionName
  • RestrictionName
  • RestrictionDefault
  • RestrictionNumber
Tables collection
  • table_schema (Owner)
  • table_name (Table)
  • table_type (TableType)
UserDefinedTypes collection
  • data_type
  • default
  • precision
  • scale
Users collection
  • user_name (UserName)
  • resource_auth
  • database_auth
  • schedule_auth
  • user_group
ViewColumns collection
  • view_schema (Owner)
  • view_name (Name)
  • column_name (Column)
Views collection
  • view_schema (Owner)
  • view_name (Name)

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
C – computed column
D – default
F – SQLJ function
L – log
N – partition condition
P – Transact-SQL or SQLJ procedure
PR – prepare objects (created by Dynamic SQL)
R – rule
RI – referential constraint
S – system table
TR – trigger
U – user table
V – view
XP – extended stored procedure
*/
 
SELECT * FROM sys.systable
 
SELECT * FROM sysobjects WHERE type = 'U'
select * from customer   --- 查-詢錶
go
 
SELECT * FROM syscolumns
GO
SELECT * FROM sysobjects
GO
 
 
SELECT sys.sysuserperm.user_name
          + '.'
          + sys.systable.table_name
          + '.'
          + sys.syscolumn.column_name
   FROM sys.systable,
        sys.syscolumn,
        sys.sysuserperm
  WHERE sys.systable.table_id = sys.syscolumn.table_id
    AND sys.systable.creator = sys.sysuserperm.user_id
    AND sys.sysuserperm.user_name NOT IN ( 'SYS', 'dbo' )
    AND sys.systable.table_name NOT LIKE 'pbcat%'
  ORDER BY sys.sysuserperm.user_name,
        sys.systable.table_name,
        sys.syscolumn.column_id
GO
 
SELECT b.name + '.' + a.name
  FROM sysobjects a, sysusers b
 WHERE a.type IN ('U', 'S')
   AND a.uid = b.uid
 ORDER BY b.name, a.name

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.Odbc;
using System.Data.SqlClient;
 
 
namespace SQLanyWhereDemo
{
 
    /// <summary>
    /// http://dcx.sybase.com/1101/en/dbprogramming_en11/ianywhere-data-sqlanywhere-saconnection-getschem6330755502-0.html
    /// </summary>
    public partial class Form3 : Form
    {
 
        string connectionString = @"DSN=geovindu;UID=dba;PWD=sql;";
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        DataTable setDatat()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("id", typeof(int));
            dt.Columns.Add("name", typeof(string));
            dt.Rows.Add(1, "Procedures");
            dt.Rows.Add(2, "DataTypes");
            dt.Rows.Add(3, "Foreign Keys");
            dt.Rows.Add(4, "Databases");
            dt.Rows.Add(5, "DBA");
            dt.Rows.Add(6, "Arguments");
            dt.Rows.Add(7, "Collection Name");
            dt.Rows.Add(8, "DatasourceInformation");
            dt.Rows.Add(9, "MetaDataCollections");
            dt.Rows.Add(10, "ForeignKeyColumns");
            dt.Rows.Add(11, "Functions");
            dt.Rows.Add(12, "IndexColumns");
            dt.Rows.Add(13, "Indexes");
            dt.Rows.Add(14, "PrimaryKeys");
            dt.Rows.Add(15, "ReservedWords");
            dt.Rows.Add(16, "Restrictions");
            dt.Rows.Add(17, "Triggers");
            dt.Rows.Add(18, "UDFs");
            dt.Rows.Add(19, "UniqueKeys");
            dt.Rows.Add(20, "UserPrivileges");
            dt.Rows.Add(21, "Users");
            dt.Rows.Add(22, "ViewColumns");
 
            //DataTable dt = connection.GetSchema("Tables", strRestricted);
            dt.Rows.Add(23, "Tables");
            dt.Rows.Add(24, "Columns");//表的列的详细,有主键TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME,ORDINAL_POSITION,COLUMN_DEFAULT,IS_NULLABLE,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,NUMERIC_PRECISION,NUMERIC_SCALE,DATETIME_PRECISION,CHARACTER_SET_NAME,COLLATION_NAME,COLUMN_TYPE,COLUMN_KEY,EXTRA,PRIVILEGES,COLUMN_COMMENT
            dt.Rows.Add(25, "Views");
            dt.Rows.Add(26, "Indexes");//表的列
            dt.Rows.Add(27, "IndexColumns");//主键
 
            return dt;
        }
 
        /// <summary>
        ///
        /// </summary>
        public Form3()
        {
            InitializeComponent();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form3_Load(object sender, EventArgs e)
        {
            this.txtConnection.Text = connectionString;
            this.comboBox1.DataSource = setDatat();
            this.comboBox1.DisplayMember = "name";
            this.comboBox1.ValueMember = "id";
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                using (OdbcConnection connection = new OdbcConnection(connectionString))
                {
                    connection.Open();
                    DataTable dt = connection.GetSchema(this.comboBox1.Text.Trim());
                    this.dataGridView1.DataSource = dt;
 
                }
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }
    }
}

  

 

SELECT * FROM master.dbo.sysservers

SELECT * FROM Utilities.dbo.sysservers

sp_addremotelogin logical_name

SELECT * FROM master.dbo.sysservers WHERE srvname = “logical_name“

sp_addremotelogin logical_name, local_user_name


create database proxy_db_name on default = 200M with default_location = ‘logical_name.remote_db_name..’

disk init name=”proxy_dev“, physname=”/var/sybase/ASE/proxy_dev.dat“, size=”200M”


select name from proxy_db_name..sysobjects


select name from sademo..sysobjects


alter database proxy_db_name for proxy_update

posted @   ®Geovin Du Dream Park™  阅读(492)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
历史上的今天:
2017-02-09 安装SQL server 2016遇到问题
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示