-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_key_cluster_stats.txt
67 lines (58 loc) · 1.93 KB
/
get_key_cluster_stats.txt
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
$dataTypeMap:=New collection
$dataTypeMap[1]:="boolean"
//
$dataTypeMap[3]:="16-bit integer"
$dataTypeMap[4]:="32-bit integer"
$dataTypeMap[5]:="64-bit integer"
$dataTypeMap[6]:="real"
$dataTypeMap[7]:="float"
$dataTypeMap[8]:="date"
$dataTypeMap[9]:="time"
$dataTypeMap[10]:="text inside record"
//11
$dataTypeMap[12]:="picture"
$dataTypeMap[13]:="UUID"
$dataTypeMap[14]:="text outside record"
//15
//16
//17
$dataTypeMap[18]:="BLOB"
$dataTypeMap[19]:="text inside record" //utf8
$dataTypeMap[20]:="text outside record" //utf8
$dataTypeMap[21]:="object"
ARRAY TEXT($fields;0)
//1-field
Begin SQL
SELECT DISTINCT(CONCAT(CONCAT(CONCAT('[:',_USER_COLUMNS.TABLE_ID),']:'),_USER_COLUMNS.COLUMN_ID))
FROM _USER_CONS_COLUMNS,_USER_COLUMNS,_USER_CONSTRAINTS,_USER_INDEXES,_USER_IND_COLUMNS
WHERE _USER_CONSTRAINTS.CONSTRAINT_TYPE= '4DR'
AND _USER_CONSTRAINTS.CONSTRAINT_ID = _USER_CONS_COLUMNS.CONSTRAINT_ID
AND _USER_COLUMNS.TABLE_ID = _USER_CONSTRAINTS.RELATED_TABLE_ID
AND _USER_COLUMNS.COLUMN_ID = _USER_CONS_COLUMNS.RELATED_COLUMN_ID
AND _USER_COLUMNS.TABLE_ID = _USER_IND_COLUMNS.TABLE_ID
AND _USER_COLUMNS.COLUMN_ID = _USER_IND_COLUMNS.COLUMN_ID
AND _USER_INDEXES.INDEX_ID = _USER_IND_COLUMNS.INDEX_ID
AND (_USER_INDEXES.INDEX_TYPE = 3 AND _USER_INDEXES.KEYWORD = FALSE)
INTO :$fields;
End SQL
ARRAY LONGINT($pos;0)
ARRAY LONGINT($len;0)
$results:=New collection
C_LONGINT($type)
If (Size of array($fields)#0)
For ($i;1;Size of array($fields))
If (Match regex("(\\d+)\\D+(\\d+)";$fields{$i};1;$pos;$len))
$tn:=Num(Substring($fields{$i};$pos{1};$len{1}))
$fn:=Num(Substring($fields{$i};$pos{2};$len{2}))
Begin SQL
SELECT DATA_TYPE
FROM _USER_COLUMNS
WHERE TABLE_ID = :$tn
AND COLUMN_ID = :$fn
INTO :$type;
End SQL
$results.push(New collection($dataTypeMap[$type];Parse formula($fields{$i};Formula out with tokens)).join("\t"))
End if
End for
End if
SET TEXT TO PASTEBOARD($results.join("\r"))