查詢mysql表結構的語句 查詢表結構的slq語句

2021-10-18 03:06:18 字數 685 閱讀 9308

1.mysql 和 sqlserver 資料庫:

檢視表結構:

select * from information_schema.columns where table_name=『表名『

修改字段長度:

alter table 表名 alter column 欄位名 字段型別(字段長度)

oracle 資料庫:

檢視表結構:

select * from user_tab_columns where table_name = 『表名『;

修改字段長度:

alter table 表名 modify 欄位名 字段型別(字段長度)

2.all_tab_columns與user_tab_columns的區別

1)select column_name,data_type,data_length from all_tab_columns

where table_name=upper(『表名『) and owner=upper(『資料庫登入使用者名稱『)

2)select column_name,data_type from all_tab_columns where table_name = 『『

以上sql語句會將所有使用者下的相同表名的列都查詢出來,造成重複和錯誤。

在只查詢某一使用者下某張表的內容時,需要使用user_tab_columns。

MySQL與Oracle表結構查詢語句

mysql select column name 欄位名稱,column type 字段型別,column default 預設值,character maximum length as 最大長度,case when is nullable no then 否 else 是 end as 是否可空,...

Sql 語句查詢表結構

sql2000系統表的應用 1 獲取當前資料庫中的所有使用者表 select name from sysobjects where xtype u and status 0 2 獲取某乙個表的所有字段 select name from syscolumns where id object id 表名...

SQL查詢表結構的語句

sql查詢表結構的語句 select case when a.colorder 1 then d.name else end 表名,a.colorder 字段序號,a.name 欄位名,case when columnproperty a.id,a.name,isidentity 1 then el...