mysql怎么只导出索引 mysql导出指定数据库

DB2如何只导出索引db2look貌似不行,可以自己写一个存储过程来实现 , 下面是我写的一个C#抽取db2表的索引,供参考 。
/// summary
/// 获得一个表的索引信息
/// /summary
/// param name="aStrDBName"数据库名/param
/// param name="aStrSchema"模式名/param
/// param name="aStrTBName"表名/param
/// returns/returns
public static DataTable GetIndexes(string aStrDBName, string aStrSchema, string aStrTBName)
{
ConnectionString cnn = GetConnection(aStrDBName);
if (cnn == null)
{
return null;
}
else
{
string strSql = @"select b.COLCOUNT, b.COLNAMES,b.IID,b.INDNAME,b.INDSCHEMA,b.TABNAME,b.TABSCHEMA,b.UNIQUERULE,b.REMARKS
from syscat.INDEXES b
where b.TABSCHEMA = '{0}' and b.TABNAME = '{1}'
order by b.IID";
strSql = string.Format(strSql, aStrSchema, aStrTBName);
return SQLHelper.ExecuteDataTable(cnn, strSql);
}
}
/// summary
/// 获得索引语句信息
/// /summary
/// param name="aStrDBName"数据库名/param
/// param name="aStrSchema"模式名/param
/// param name="aStrTBName"表名/param
/// param name="aStrTerminator"语句终结符/param
/// returns/returns
public static string GetIndexesInfo(string aStrDBName, string aStrSchema, string aStrTBName, string aStrTerminator)
{
return GetIndexesInfo(GetIndexes(aStrDBName, aStrSchema, aStrTBName), aStrTerminator);
}
/// summary
/// 获得索引语句信息
/// /summary
/// param name="aDtIndexes"索引表/param
/// param name="aStrTerminator"语句终结符/param
/// returns/returns
public static string GetIndexesInfo(DataTable aDtIndexes, string aStrTerminator)
{
string strInfo = "";
if (aDtIndexes != null)
{
foreach (DataRow drIndex in aDtIndexes.Rows)
{
if (drIndex["UNIQUERULE"].ToString().Trim() != "P")
{
strInfo += "\r\n\r\n";
strInfo += string.Format("CREATE {4}INDEX {0}.{1}\r\nON {2}.{3}\r\n{5}{6}",
drIndex["INDSCHEMA"].ToString().Trim(), drIndex["INDNAME"].ToString().Trim(),
drIndex["TABSCHEMA"].ToString().Trim(), drIndex["TABNAME"].ToString().Trim(),
drIndex["UNIQUERULE"].ToString().Trim() == "U" ? "UNIQUE " : "",
GetIndexColumnsInfo(drIndex["COLNAMES"].ToString().Trim()), aStrTerminator);
}
}
}
return strInfo;
}
/// summary
/// 获得索引的列字段
/// /summary
/// param name="aStrColNames"索引列字符串/param
/// returns/returns
private static string GetIndexColumnsInfo(string aStrColNames)
{
aStrColNames = aStrColNames.Replace("+", ",ASC ").Replace("-", ",DESC ");//替换升序降序符号
string[] strCols = aStrColNames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
aStrColNames = "(";
foreach (string s in strCols)
{
aStrColNames += s.Substring(s.IndexOf(" ") + 1) + " " + s.Substring(0, s.IndexOf(" ")) + ",";
}
aStrColNames = aStrColNames.TrimEnd(new char[] { ',' }) + ")";
return aStrColNames;
}
sqlserver数据库 怎么批量导出索引sqlserver数据库 怎么批量导出索引
索引是建立在表mysql怎么只导出索引的基础上mysql怎么只导出索引的 。所以SQL Server 2008没有提供只导出索引脚本的选项 。
可以在导出向导中将选项"生成索引脚本(Script Indexes)"设置为True,然后在对象类型中只选择“表(Tables)".这样导出的脚本中就包含了索引的脚本mysql怎么只导出索引,当然也包括表的脚本 。如果不需要表的脚本,手工把它们删掉或者注释掉即可 。
mysql 导出不要数据 , 但索引必须要使用下面SQL命令show create就可以,例如下面的命令显示数据库web里面表clubuser的你需要的信息:

推荐阅读