mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 11:26:00 +00:00
mssql indexes analyse WIP
This commit is contained in:
@@ -117,6 +117,9 @@ class MsSqlAnalyser extends DatabaseAnalyser {
|
||||
createSql: getCreateSql(row),
|
||||
}));
|
||||
|
||||
const indexesRows = await this.driver.query(this.pool, this.createQuery('indexes', ['tables']));
|
||||
const indexcolsRows = await this.driver.query(this.pool, this.createQuery('indexesindexcols', ['tables']));
|
||||
|
||||
return {
|
||||
tables,
|
||||
views,
|
||||
|
||||
@@ -8,6 +8,8 @@ const views = require('./views');
|
||||
const programmables = require('./programmables');
|
||||
const viewColumns = require('./viewColumns');
|
||||
const getSchemas = require('./getSchemas');
|
||||
const indexes = require('./indexes');
|
||||
const indexcols = require('./indexcols');
|
||||
|
||||
module.exports = {
|
||||
columns,
|
||||
@@ -20,4 +22,6 @@ module.exports = {
|
||||
programmables,
|
||||
viewColumns,
|
||||
getSchemas,
|
||||
indexes,
|
||||
indexcols,
|
||||
};
|
||||
|
||||
7
plugins/dbgate-plugin-mssql/src/backend/sql/indexcols.js
Normal file
7
plugins/dbgate-plugin-mssql/src/backend/sql/indexcols.js
Normal file
@@ -0,0 +1,7 @@
|
||||
module.exports = `
|
||||
select c.object_id, c.index_id, c.column_id, c.is_descending_key, c.is_included_column from sys.index_columns c
|
||||
|
||||
where c.object_id =OBJECT_ID_CONDITION
|
||||
order by c.key_ordinal
|
||||
|
||||
`;
|
||||
14
plugins/dbgate-plugin-mssql/src/backend/sql/indexes.js
Normal file
14
plugins/dbgate-plugin-mssql/src/backend/sql/indexes.js
Normal file
@@ -0,0 +1,14 @@
|
||||
module.exports = `
|
||||
select i.object_id as objectId, i.name as constraintName, i.type_desc, i.is_unique as isUnique,i.index_id, i.is_unique_constraint from sys.indexes i
|
||||
where i.is_primary_key=0
|
||||
and i.is_hypothetical=0 and indexproperty(i.object_id, i.name, 'IsStatistics') = 0
|
||||
and objectproperty(i.object_id, 'IsUserTable') = 1
|
||||
and i.index_id between 1 and 254
|
||||
|
||||
--and i.name not in
|
||||
-- (select o.name from sysobjects o
|
||||
-- where o.parent_obj = i.object_id
|
||||
-- and objectproperty(o.id, N'isConstraint') = 1.0)
|
||||
|
||||
and i.object_id =OBJECT_ID_CONDITION
|
||||
`;
|
||||
Reference in New Issue
Block a user