數(shù)據(jù)庫與基本表操作 表是數(shù)據(jù)庫什么的操作依據(jù)?
表是數(shù)據(jù)庫什么的操作依據(jù)?表是數(shù)據(jù)庫中最基本的操作對象,也是整個(gè)數(shù)據(jù)庫系統(tǒng)的數(shù)據(jù)來源。如何用數(shù)據(jù)庫自連接建立表格?1、打開——“開始”,選擇——“所有程序”,找打“Microsoft SQL Serv
表是數(shù)據(jù)庫什么的操作依據(jù)?
表是數(shù)據(jù)庫中最基本的操作對象,也是整個(gè)數(shù)據(jù)庫系統(tǒng)的數(shù)據(jù)來源。
如何用數(shù)據(jù)庫自連接建立表格?
1、打開——“開始”,選擇——“所有程序”,找打“Microsoft SQL Server 2005”單擊打開,然后選擇——“SQL Server Management Studio Express”單擊打開。
2、打開后,這里有兩種選擇,“Windows身份驗(yàn)證”和“SQL Server身份驗(yàn)證”,兩種下都可以建表,只是后期表的擁有著不一樣。
3、選擇
數(shù)據(jù)庫表樣本數(shù)據(jù)怎么建立?
、 使用向?qū)Ы?shù)據(jù)庫
特點(diǎn):可以方便快捷地創(chuàng)建數(shù)據(jù)庫,但只適用于一般常用的數(shù)據(jù)庫。
2、 使用數(shù)據(jù)庫設(shè)計(jì)器建立數(shù)據(jù)庫
特點(diǎn): 最大特點(diǎn)就是靈活性
操作步驟:⑴“文件”菜單“新建”,顯示新建對話框
⑵選擇“數(shù)據(jù)庫”和單擊“新建文件”鈕
⑶在創(chuàng)建對話框中輸入新數(shù)據(jù)庫的名稱和單擊“保存”鈕
效果:數(shù)據(jù)庫文件已經(jīng)建立完成。
顯示出“數(shù)據(jù)庫設(shè)計(jì)器”窗口和“數(shù)據(jù)庫設(shè)計(jì)工具”
打開“數(shù)據(jù)庫設(shè)計(jì)器”工具方法:“顯示”菜單“工具欄”
選擇“數(shù)據(jù)庫設(shè)計(jì)器”
pg數(shù)據(jù)庫常用操作?
pg數(shù)據(jù)庫的常用操作有以下幾種:
一、查詢
1)查詢進(jìn)程:
select * from pg_stat_activity
說明:
datname表示數(shù)據(jù)庫名
procpid表示當(dāng)前的SQL對應(yīng)的PID
query_start表示SQL執(zhí)行開始時(shí)間
current_query表示當(dāng)前執(zhí)行的SQL語句
waiting表示是否正在執(zhí)行,t表示正在執(zhí)行,f表示已經(jīng)執(zhí)行完成
client_addr表示客戶端IP地址
2)kill進(jìn)程:
kill有兩種,
第一種是:
SELECT pg_cancel_backend(PID)
第二種是:
SELECT pg_terminate_backend(PID)
3)查詢連接數(shù)
SELECT count(*) FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s
二、授權(quán)
1)sequence授權(quán),跟table授權(quán)有區(qū)別
grant usage,select on sequence ltsequence_namegt to ltrolegt
三、查詢size
1、sql查詢
postgres# select pg_size_pretty(pg_database_size(#39postgres#39))
2 、linux du查詢
postgres# SELECT oid from pg_database where datname#39postgres#39
oid
-------
21360
查看名稱為21360的文件的大小即是數(shù)據(jù)庫postgres的大小
四、解鎖,注意要先連接到表所在的database
c ampdbname
select distinct , from pg_class a,pg_locks b where and and like #39%amptable_name%#39
select pg_terminate_backend(amppid)
五、查詢哪些表占用的空間大。
SELECT table_schema || #39.#39 || table_name AS table_full_name,
pg_size_pretty(pg_total_relation_size(#39#34#39 || table_schema || #39#34.#34#39 || table_name || #39#34#39)) AS size
FROM information_
where table_name like #39%awr%#39
ORDER BY
pg_total_relation_size(#39#34#39 || table_schema || #39#34.#34#39 || table_name || #39#34#39) DESC