Sequences

SELECT s.seq_id,
o.objname,
format_objectname(o.objname, o.objclass) format_objname,
s.data_type, s.min_value, s.max_value, CASE WHEN s.cycle THEN 1 ELSE 0 END cycle, s.increment, s.cache_size, s.next_cache_val, s.flags,
u.usename owner,
o.objcreated createdate,
c.classname objtype,
d.objname database
FROM _t_object o
INNER JOIN _t_object_classes c ON o.objclass = c.objclass AND o.objclass IN (4909, 4923, 4933)
INNER JOIN _t_object d ON o.objdb = d.objid AND d.objname = ‘MY_DATABASE’
INNER JOIN _t_user u ON o.objowner = u.usesysid
INNER JOIN _vt_sequence s ON o.objid = s.seq_id AND o.objdb = s.db_id
WHERE o.objname = ‘SEQ_CUSTOMER_ID’;
SELECT ‘ALTER SEQUENCE ‘||o.objname||’ RESTART WITH ‘||CAST(s.next_cache_val AS VARCHAR(100))||’;’ script,
s.seq_id,
o.objname,
–format_objectname(o.objname, o.objclass) format_objname,
s.data_type, s.min_value, s.max_value, CASE WHEN s.cycle THEN 1 ELSE 0 END cycle, s.increment, s.cache_size, s.next_cache_val, s.flags,
u.usename owner,
o.objcreated createdate,
c.classname objtype,
d.objname database
FROM _t_object o
INNER JOIN _t_object_classes c ON o.objclass = c.objclass AND o.objclass IN (4909, 4923, 4933)
INNER JOIN _t_object d ON o.objdb = d.objid AND d.objname = ‘MY_DATABASE’
INNER JOIN _t_user u ON o.objowner = u.usesysid
INNER JOIN _vt_sequence s ON o.objid = s.seq_id AND o.objdb = s.db_id