Table structure Export method for database users

Source: Internet
Author: User

Create VIEW Temp_view as

(Select B.column_name,a.table_name,b.column_id,b.data_type

From User_tables A,user_tab_columns b where a.table_name=b.table_name);


------------------------------------------

SELECT * from Temp_view order by table_name,column_id;



------------------------------------------

Spool Create_table.sql;


Select TT from

(SELECT ' CREATE TABLE ' tt,table_name,0.1 column_id from User_tables u

UNION ALL

Select Table_name| | ' (', table_name,0.2 column_id from User_tables u

UNION ALL

Select Column_name| | ' ' | | data_type| | ', ', t.table_name,column_id from User_tables U,temp_view t where u.table_name=t.table_name

UNION ALL

Select '), ', table_name,999 column_id from user_tables u) temp

--where table_name<> ' temp_table '

Order BY table_name,column_id;


Spool off;


sql> @create_table. sql



This article is from the DBA Sky blog, so be sure to keep this source http://joeyzhang.blog.51cto.com/7594056/1671846

Table structure Export method for database users

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.