Table column name is more time, manual write column name is more troublesome, this function can let a person secretly lazy
Create or Replace function F_getcols (p_tablename in varchar2/* gets all column names in the table before and after you add select from*/) RETURN varchar2
Is
Result VARCHAR2 (2000);
V_cnts number;
V_strtabname VARCHAR2 (200);
BEGIN
V_strtabname:=upper (P_tablename);
Select COUNT (1) into v_cnts from User_tables where table_name=v_strtabname;
If V_cnts>0 Then
result:= ' SELECT ';
For CR in (select column_name from User_tab_columns where table_name=v_strtabname order by column_id)
Loop
result:=result| | cr.column_name| | ', ';
End Loop;
Result:=substr (Result,1,length (Result)-1);
result:=result| | ' from ';
Else
result:= ' table does not exist ';
End If;
return (Result);
END F_getcols;
How to use
Select F_getcols (' table name ') from dual;
Oracle generates column names for the specified table and adds a select from before and after