在Sybase中查找表的索引

时间:2012-03-07 09:27:21

标签: sql environment-variables sybase indexing

我目前正在一个双盲的环境中工作。

  1. 我必须通过电子邮件将我需要运行的任何查询通过电子邮件发送给客户
  2. 该员工在SAS客户端中运行它们,并与SyBase建立了odbc连接
  3. 我需要找出如何确定特定表上存在哪些索引。我会使用sp_helpindex,但显然它在SyBase的实例上不存在。

    我们相信它是SyBase 12,但我再也无法确定。

    有没有人为...提供SQL - 确切确认我们正在研究的S​​yBase版本是什么? - 给定表存在的所有索引的详细信息?

6 个答案:

答案 0 :(得分:3)

大多数Sybase产品都有一个-v命令行参数来告诉版本是否运行引擎。

要查找任何表格上的索引,请输入以下内容,其中my_table是您的表格名称:

select i.name 
from sysindexes i, sysobjects o
where o.name = 'my_table'
  and o.id = i.id

答案 1 :(得分:1)

要“确切确认我们正在处理哪种版本的SyBase?”

为什么不使用:

  

选择@@ version


Sybase网站已关闭(至少在这里),但它会是这样的:

IQ SHOW INDEXSET INDEXES

IQ SHOW INDEXSET FOR indexset

其中indexsettablename,因为每个表都有一个分配了相同名称的索引集。

如果您可以访问sybase网站,可以进一步:)

答案 2 :(得分:0)

您可以使用此查询:

foreach key [array names a] {
    set count [expr $a($key)]
    puts $count
}

答案 3 :(得分:0)

在多个表上查找索引,而不是像图像索引

select name = o.name,iname = i.name from sysindexes i, sysobjects o where o.name in ('table1','table2','table3') and i.name not like 't%' and i.indid >=1 and o.id = i.id

答案 4 :(得分:0)

对于sybase版本:

select @@version

在Sybase版SAP IQ / 16中,您可以获得以下索引列表(表名为my_table,区分大小写:

select *
from sys.sysindexes
where tname = 'my_table';

答案 5 :(得分:0)

{% block content %} <div class="form_div" style="width:60%;"> <h2>Campaign Form</h2> <form method="POST"> {% csrf_token %} {% for field in form.visible_fields %} <div class="form-group"> {{ field.label_tag }} {% render_field field class="form-control" %} {% if field.help_text %} <small class="form-text text-muted">{{ field.help_text }}</small> {% endif %} </div> {% endfor %} <div style="display: flex; justify-content: space-between; width: 280px;"> <h3>Rules</h3> <button type="button" id="generate-rule" class="btn btn-primary">+</button> </div> <div class="parent"> <div> {{ rule_formset.management_form }} {% for ruleForm in rule_formset %} {{ ruleForm }} <input type="button" class="btn btn-warn" style="background: red;" value="-"> {% endfor %} </div> </div> <div style="display: flex; justify-content: space-between; width: 280px;"> <h3>Milestone Rules</h3> <button type="button" id="generate-milestone-rule" class="btn btn-primary">+</button> </div> <div class="milestone-parent"> <div> {{ milestone_formset.management_form }} {% for milestoneForm in milestone_formset %} {{ milestoneForm }} <input type="button" class="btn btn-warn" style="background: red;" value="-"> {% endfor %} </div> </div> <div> <input type="submit" value="Post"> </div> </form> </div> <script> $(function () { $("#id_startDate").datetimepicker({ format: 'd/m/Y H:i', }); $("#id_endDate").datetimepicker({ format: 'd/m/Y H:i', }); }); </script> <script type='text/javascript'> const ruleform = ` <div> <label for="id_rules-{n}-eventName">Event Name:</label> <input type="text" name="rules-{n}-eventName" maxlength="200" id="id_rules-{n}-eventName"> <label for="id_rules-{n}-operator">Operator:</label> <select name="rules-{n}-operator" id="id_rules-{n}-operator"> <option value="EQUAL">EQUAL</option> <option value="EVERY">EVERY</option> </select> <label for="id_rules-{n}-value">Value:</label> <input type="number" name="rules-{n}-value" id="id_rules-{n}-value"> <input type="button" class="btn btn-warn" style="background: red;" value="-"> </div> ` const milestoneform = ` <div> <label for="id_milestones-{n}-operator">Operator:</label> <select name="milestones-{n}-operator" id="id_milestones-{n}-operator"> <option value="EQUAL">EQUAL</option> <option value="EVERY">EVERY</option> </select> <label for="id_milestones-{n}-value">Value:</label> <input type="number" name="milestones-{n}-value" id="id_milestones-{n}-value"> <label for="id_milestones-{n}-mreferrerCredits">Referrer Credits:</label> <input type="number" name="milestones-{n}-mReferrerCredits" maxlength="200" id="id_milestones-{n}-mReferrerCredits"> <input type="button" class="btn btn-warn" style="background: red;" value="-"> </div> ` $("#generate-rule").on('click', function(e){ var n = $("#id_rules-TOTAL_FORMS").val(); // current number of forms; var new_form = ruleform.replace(/{n}/g, n); // replace all {n} by the new form number $(".parent").append(new_form); $("#id_rules-TOTAL_FORMS").val(parseInt(n) + 1); // update the total forms number console.log($("#id_rules-TOTAL_FORMS").val()); }) $("#generate-milestone-rule").on('click', function(e){ var n = $("#id_milestones-TOTAL_FORMS").val(); // current number of forms; var new_form = milestoneform.replace(/{n}/g, n); // replace all {n} by the new form number $(".milestone-parent").append(new_form); $("#id_milestones-TOTAL_FORMS").val(parseInt(n) + 1); // update the total forms number console.log($("#id_milestones-TOTAL_FORMS").val()); }) $(".parent").on("click", (e) => { //n = $("#id_rules-TOTAL_FORMS").val(); //$("#id_rules-TOTAL_FORMS").val(parseInt(n)-1); //console.log($("#id_rules-TOTAL_FORMS").val()); return e.target.classList.contains('btn-warn') && e.target.parentNode.remove() }) $(".milestone-parent").on("click", (e) => { //n = $("#id_milestones-TOTAL_FORMS").val(); //$("#id_milestones-TOTAL_FORMS").val(parseInt(n)-1); //console.log($("#id_milestones-TOTAL_FORMS").val()); return e.target.classList.contains('btn-warn') && e.target.parentNode.remove() }) </script> {% endblock %}

尝试上面的代码,对我有用。