MySQL (C API)VC執行個體及代碼下載 (1)(5)

來源:互聯網
上載者:User


11.4. 通過SQL語句來更改使用者的密碼

修改別人的,需要sysadmin role

EXEC sp_password NULL, 'newpassword', 'User'

如果帳號為SA執行EXEC sp_password NULL, 'newpassword', sa

11.5. 怎麼判斷出一個表的哪些欄位不允許為空白?

select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where IS_NULLABLE='NO' and TABLE_NAME=tablename

11.6. 如何在資料庫裡找到含有相同欄位的表?

a. 查已知列名的情況

SELECT b.name as TableName,a.name as columnname

From syscolumns a INNER JOIN sysobjects b

ON a.id=b.id

AND b.type='U'

AND a.name='你的欄位名字'

b. 未知列名查所有在不同表出現過的列名

Select o.name As tablename,s1.name As columnname

From syscolumns s1, sysobjects o

Where s1.id = o.id

And o.type = 'U'

And Exists (

Select 1 From syscolumns s2

Where s1.name = s2.name

And s1.id <> s2.id

)

11.7. 查詢第xxx行資料

假設id是主鍵:

select *

from (select top xxx * from yourtable) aa

where not exists(select 1 from (select top xxx-1 * from yourtable) bb where aa.id=bb.id)

如果使用遊標也是可以的

fetch absolute [number] from [cursor_name]

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.