Function: The application of the corresponding SQL statements, can be convenient and quick query Oracle database specified users of all user table description, quickly know what each data table is to do, easy to write documents and programs.
Operating Environment: Build Oracle Database and use the Pq/sql developer software and the specified database account password to connect to the database you are querying.
Detailed contents are as follows:
1, the use of SQL query script is as follows:---------------------------------------------------------------------------------------------- -----------------
--oracle use cursors to query all datasheet comments
Declare
Mytablename NVARCHAR2 (200): = '; --Define the data table name variable to query
Mytablecomment NVARCHAR2 (200): = '; --Define the datasheet annotation variable to query
Commentsql VARCHAR2 (2000): = '; --Define the annotation result variable to output
Cursor MyCursor1 is select * to User_tab_comments ORDER by table_name;--define Cursors
Myrecord1 Mycursor1%rowtype; --Define Cursor record type
Begin
Open MyCursor1; --Open cursor
If Mycursor1%isopen then--judgment opened successfully
Loop--Looping to get recordsets
Fetch MyCursor1 into myrecord1;
If Mycursor1%found then--the found property of the cursor determines whether there is a record
Begin
Mytablename:=myrecord1.table_name;
mytablecomment:=myrecord1.comments;
--commentsql:= ' table name ' | | mytablename| | ' Comments as ' | | Mytablecomment;
commentsql:=mytablename| | ' '|| Mytablecomment;
Dbms_output.put_line (Commentsql);
End
Else
Exit --Get the records in the cursor
End If;
End Loop;
Else
Dbms_output.put_line (' Cursors not open ');
End If;
Close MyCursor1;
End
---------------------------------------------------------------------------------------------------------------
2, Pl/sql Developer in the operation of a: Copy the above query script to the "SQL" tab, and execute the query, screenshot as follows:
3, Pl/sql developer Operation Two: switch to the "Output" tab, view the results, screenshot as follows:
---------------------------------------------------------------------------------------------------------------