SQL 系統表的操作

2021-04-14 14:19:23 字數 697 閱讀 7994

--1:獲取當前資料庫中的所有使用者表

select name from sysobjects where xtype='u' and status>=0

--2:獲取某乙個表的所有字段

select name from syscolumns where id=object_id('表名')

select a.* from sysobjects a, syscomments b where a.id = b.id and b.text like '%表名%'

--4:檢視當前資料庫中所有儲存過程

select name as 儲存過程名稱 from sysobjects where xtype='p'

--5:查詢使用者建立的所有資料庫

select * from master..sysdatabases d where sid not in(select sid from master..syslogins where name='sa')

或者select dbid, name as db_name from master..sysdatabases where sid <> 0x01

--6:查詢某乙個表的字段和資料型別

select column_name,data_type from information_schema.columns

where table_name = '表名'  

SQL基本表的操作

create table 表名 列名 資料型別 列級完整性約束條件 列名 資料型別 列級完整性約束條件 表級完整性約束條件 如果完整性約束條件涉及到該錶的多個屬性列,則必須定義在表級上,否則既可以定義在列級也可以定義在表級。ag.建立 學生 表student,學號是主碼,姓名取值唯一。create ...

oracle 操作表的sql

新建表 create table table1 id varchar 300 primary key,name varchar 200 not null 插入資料 insert into table1 id,name values aa bb 更新資料 update table1 set id bb...

Sql 常用表操作

1 建立表 create tabletable name field name data type not null null primary key 若仿照另乙個表來新建該錶用 create table as create table table name1 as select coumn1,co...