我有一个创建表tab1
function searchObj (obj, query) {
var foundObj = null;
Object.keys(obj).forEach(function(key) {
var value = obj[key];
if (typeof value === 'object') {
foundObj = searchObj(value, query);
}
if (typeof value === 'string' && value.toLowerCase().indexOf(query.toLowerCase()) > -1) {
foundObj = obj;
}
});
return foundObj;
}
var demoData=[
{id:1,desc:{original:'trans1'},date:'2017-07-16'},
{id:2,desc:{original:'trans2'},date:'2017-07-12'},
{id:3,desc:{original:'trans3'},date:'2017-07-11'},
{id:4,desc:{original:'trans4'},date:'2017-07-15'}
];
var searchFilter = demoData.filter(function(obj){
return searchObj(obj, 'trans1');
});
console.log(searchFilter);
我已经厌倦了使用以下代码选择列标题:
CREATE DEFINER=`masteruser`@`%` FUNCTION `GET_NEXT_SEQ`(`SEQNAME` VARCHAR(50)) RETURNS varchar(50) CHARSET utf8
BEGIN
DECLARE CURVALUE INT;
UPDATE sequence_log SET CURRENT_VALUE = (CURRENT_VALUE + 1) WHERE SEQUENCE_NAME = SEQNAME;
SELECT CURRENT_VALUE INTO CURVALUE FROM sequence_log WHERE SEQUENCE_NAME = SEQNAME;
RETURN LPAD(CURVALUE,9,0);
END
我想使用列标题创建一个视图。
答案 0 :(得分:0)
您可以在user_tab_cols
视图中找到有关列的信息。
您可以使用以下查询检索列标题:
SELECT COLUMN_NAME FROM USER_TAB_COLS WHERE TABLE_NAME = 'TAB1'
如果您没有作为表所有者连接,则可以使用它(确保模式和表名称是大写字母):
SELECT COLUMN_NAME FROM ALL_TAB_COLS WHERE TABLE_NAME = 'TAB1'
AND OWNER = 'MYSCHEMA'