sqlserver 運算元據表語句模板

2022-02-21 05:27:17 字數 1533 閱讀 6288

從網上搜的,一點一點加吧。

--

---------設定事務全部回滾-----------------

set xact_abort on

begin

begin

try

begin

transaction

tr--

-------------------------------刪除表********************===

--drop table t_questionbankitem

---******************************===修改列名****************************************

--exec sp_rename 't_mycourse.courseclassid' , 'classid', 'column'

-----*************************=修改字段型別及預設值------------------

--alter table t_message alter column title nvarchar(20) not null

--*************************==增加列***********************************===----

----------------t_assnews-------------

--alter table t_assnews add viewcount int not null default 0

--exec sys.sp_addextendedproperty @name=n'ms_description', @value=n'瀏覽量' , @level0type=n'schema',@level0name=n'dbo', @level1type=n'table',@level1name=n't_assnews', @level2type=n'column',@level2name=n'viewcount'

-----------刪除字段、先刪除約束

--alter table [dbo].[t_ticategory] drop constraint [df_t_ticategory_traininginstitutionid]

--alter table t_ticategory drop column traininginstitutionid

commit

transaction

tr

endtry

begin

catch

print

'executed failed';

select error_number() as

error_number ,

error_message()

aserror_message

rollback

transaction

tr

return

endcatch

end

python運算元據庫語句 Python運算元據庫

pymysql模組簡單實用 1 安裝pymysql模組 pip3 install pymysql 2 建立連線 與mysql服務端建立連線 conn pymysql.connect host 127.0.0.1 ip port 3306,埠 user root 資料庫使用者名稱 password 1...

用SQL語句運算元據

語法 insert into 表名 列名列表 values 值列表 insert into 表名 列表名1,列表名2,列表名3,列表名4 select 值列表1,值列表2,值列表3,值列表4 from 插入的表名 select 列表名1,列表名2,列表名3,列表名4 into addresslist...

MySQL SQL語句 運算元據庫

運算元據庫 sql語句說明增 create database 資料庫名 create database if not exists 資料庫名 create database if not exists 資料庫名 character set 字符集名 建立資料庫 刪drop database 資料庫名...