Oracle數(shù)據(jù)庫查詢表的基本信息
Jun 07, 2016 pm 04:55 PM因為Oracle項目某些模塊的數(shù)據(jù)結(jié)構(gòu)設(shè)計沒有嚴(yán)格按照某規(guī)范設(shè)計,所以只能從數(shù)據(jù)庫中查詢數(shù)據(jù)結(jié)構(gòu),需要查詢的信息如下:字段
??? 因為Oracle項目某些模塊的數(shù)據(jù)結(jié)構(gòu)設(shè)計沒有嚴(yán)格按照某規(guī)范設(shè)計,所以只能從數(shù)據(jù)庫中查詢數(shù)據(jù)結(jié)構(gòu),需要查詢的信息如下:字段名稱、數(shù)據(jù)類型、是否為空、默認(rèn)值、主鍵、外鍵等等。
??? 在網(wǎng)上搜索了查詢上述信息的方法,總結(jié)如下:
??? 一,查詢表基本信息
??? select
??? utc.column_name,utc.data_type,utc.data_length,utc.data_precision, utc.data_Scale,utc.nullable,utc.data_default,ucc.comments
??? from
??? user_tab_columns utc,user_col_comments ucc
??? where
??? utc.table_name = ucc.table_name and utc.column_name = ucc.column_name and utc.table_name = 'ONLINEXLS'
??? order by
??? column_id
??? 注意:order by column_id的意義是使得結(jié)果按照設(shè)計數(shù)據(jù)結(jié)構(gòu)時的順序顯示。
??? 二,查詢表主鍵
??? select
??? col.column_name
??? from
??? user_constraints con,user_cons_columns col
??? where
??? con.constraint_name=col.constraint_name and con.constraint_type='P' and col.table_name='ONLINEXLS'三,查詢表外鍵
??? select
??? distinct(ucc.column_name) column_name,rela.table_name,rela.column_name column_name1
??? from
??? user_constraints uc,user_cons_columns ucc, (select t2.table_name,t2.column_name,t1.r_constraint_name from user_constraints t1,user_cons_columns t2 where t1.r_constraint_name=t2.constraint_name and t1.table_name='ONLINEXLS') rela
??? where
??? uc.constraint_name=ucc.constraint_name and uc.r_constraint_name=rela.r_constraint_name and uc.table_name='ONLINEXLS'
??? 1、查找表的所有索引(包括索引名,類型,構(gòu)成列):
??? select t.*,i.index_type from user_ind_columns t,user_indexes i where t.index_name = i.index_name and t.table_name = i.table_name and t.table_name = 要查詢的表
??? 2、查找表的主鍵(包括名稱,構(gòu)成列)表名大寫 :
??? select cu.* from user_cons_columns cu, user_constraints au where cu.constraint_name = au.constraint_name and au.constraint_type = 'P' and au.table_name = '要查詢的表' ;
??? 僅查詢表主鍵
??? select column_name from user_cons_columns wherE CONSTRAINT_NAME in (select CONSTRAINT_NAME from user_constraints where table_name =upper('表名') and CONSTRAINT_TYPE='P');
??? 3、查找表的唯一性約束(包括名稱,構(gòu)成列):
??? select column_name from user_cons_columns cu, user_constraints au where cu.constraint_name = au.constraint_name and au.constraint_type = 'U' and au.table_name = 要查詢的表
??? 4、查找表的外鍵(包括名稱,,引用表的表名和對應(yīng)的鍵名,下面是分成多步查詢):
??? select * from user_constraints c where c.constraint_type = 'R' and c.table_name = 要查詢的表
??? 查詢外鍵約束的列名:
??? select * from user_cons_columns cl where cl.constraint_name = 外鍵名稱
??? 查詢引用表的鍵的列名:
??? select * from user_cons_columns cl where cl.constraint_name = 外鍵引用表的鍵名
??? 5、查詢表的所有列及其屬性
??? select t.*,c.COMMENTS from user_tab_columns t,user_col_comments c where t.table_name = c.table_name and t.column_name = c.column_name and t.table_name = 要查詢的

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The key to learning Java without taking detours is: 1. Understand core concepts and grammar; 2. Practice more; 3. Understand memory management and garbage collection; 4. Join online communities; 5. Read other people’s code; 6. Understand common libraries and frameworks; 7. Learn to deal with common mistakes; 8. Make a learning plan and proceed step by step. These methods can help you master Java programming efficiently.

Learning Java requires learning basic syntax, object-oriented programming, collection frameworks, exception handling, multithreading, I/O streaming, JDBC, network programming, and advanced features such as reflection and annotation. 1. The basic syntax includes variables, data types, operators and control flow statements. 2. Object-oriented programming covers classes, objects, inheritance, polymorphism, encapsulation and abstraction. 3. The collection framework involves ArrayList, LinkedList, HashSet, and HashMap. 4. Exception handling ensures program robustness through try-catch block. 5. Multithreaded programming requires understanding of thread life cycle and synchronization. 6. I/O streams are used for data reading, writing and file operations. 7. JDBC is used to interact with databases. 8. Network programming passes S

To connect Oracle database to Tableau for data visualization, you need to follow the following steps: 1. Configure Oracle database connection in Tableau, use ODBC or JDBC drivers; 2. Explore data and create visualizations, such as bar charts, etc.; 3. Optimize SQL queries and indexes to improve performance; 4. Use Oracle's complex data types and functions to implement through custom SQL queries; 5. Create materialized views to improve query speed; 6. Use Tableau's interactive functions such as dashboard for in-depth analysis.

Common SQL statements include: 1. CREATETABLE creates tables, such as CREATETABLEemployees(idINTPRIMARYKEY, nameVARCHAR(100), salaryDECIMAL(10,2)); 2. CREATEINDEX creates indexes, such as CREATEINDEXidx_nameONemployees(name); 3. INSERTINTO inserts data, such as INSERTINTO employeees(id, name, salary)VALUES(1,'JohnDoe',75000.00); 4. SELECT check

In Oracle database, the steps to configure parallel query to improve performance include: 1. Set at the database level, and implement it by modifying initialization parameters such as PARALLEL_DEGREE_POLICY and PARALLEL_MAX_SERVERS; 2. Set at the session level, adjust the parallelism of the current session through the ALTERSESSION command; 3. Consider key points such as parallelism, resource management and data distribution; 4. Improve performance by optimizing query planning, adjusting parallelism and monitoring and tuning. These steps help to take full advantage of parallel queries and significantly improve the query performance of the database.

The way to view all databases in MongoDB is to enter the command "showdbs". 1. This command only displays non-empty databases. 2. You can switch the database through the "use" command and insert data to make it display. 3. Pay attention to internal databases such as "local" and "config". 4. When using the driver, you need to use the "listDatabases()" method to obtain detailed information. 5. The "db.stats()" command can view detailed database statistics.

The steps to connect to an Oracle database connection pool using JDBC include: 1) Configure the connection pool, 2) Get the connection from the connection pool, 3) Perform SQL operations, and 4) Close the resources. Use OracleUCP to effectively manage connections and improve performance.

The key to installing MySQL 8.0 is to follow the steps and pay attention to common problems. It is recommended to use the MSI installation package on Windows. The steps include downloading the installation package, running the installer, selecting the installation type, setting the root password, enabling service startup, and paying attention to port conflicts or manually configuring the ZIP version; Linux (such as Ubuntu) is installed through apt, and the steps are to update the source, installing the server, running security scripts, checking service status, and modifying the root authentication method; no matter which platform, you should modify the default password, create ordinary users, set up firewalls, adjust configuration files to optimize character sets and other parameters to ensure security and normal use.
