如何使用sql語言創(chuàng)建數(shù)據(jù)表 如何用SQL語句給表增加字段?
如何用SQL語句給表增加字段?使用SQL語句為數(shù)據(jù)表提高一個(gè)字段,建議使用altertable子句。語法:altertable表格名set字段名數(shù)據(jù)類型-altertabletable_nameomi
如何用SQL語句給表增加字段?
使用SQL語句為數(shù)據(jù)表提高一個(gè)字段,建議使用altertable子句。
語法:altertable表格名set字段名數(shù)據(jù)類型-altertabletable_nameomitcol_namechar(5)
例,表格:tt
新增審批字符型字段:test_column
SQL語句:
altertablettmaintest_columnchar(5)
怎么使用sql語句創(chuàng)建數(shù)據(jù)庫?
第一首先在電腦上然后打開sql數(shù)據(jù)庫軟件。
然后再鼠標(biāo)右鍵點(diǎn)擊新建網(wǎng)站查詢。
使用Transact-SQL創(chuàng)建數(shù)據(jù)庫的步驟有分急求?
代碼示例:
-1--
create database test2 on(nametest2_dat,,size3MB,maxsize9MB,filegrowth8%)
login(nametest2_log,filenameD:SQLDBtest2_log.ldf,size1MB,maxsize5MB,filegrowth0)
--2.1--
usetest2
createtableXSZG1(工號(hào)char(4),姓名baichar(8),性別char(2),婚否char(4),年齡int,基本工資duint)
--2.2--
truncateintoXSZG1
select1001,李小新,男,已婚,33,1800union
select1002,趙小蕊,女,未婚,28,2200union
select1003,錢學(xué)塘zhi,男,已婚,45,3500union
select1004,李明啟,男,已婚,56,5500union
select1005,肖小風(fēng),女,沒結(jié)婚,27,1800union
select1006,黃興民dao,男,已婚,46,3300
--2.3--
createtableXSZG2(工號(hào)char(4),職稱char(12),獎(jiǎng)金int)
--2.4--
truncatearoundXSZG2
select1001,普通員工,300 unionselect 1002,技師,600union
select1003,工程師,800union
select1004,高級(jí)技師,1400union
select1005,工程師,800union
select1006,技師,600
--3--
createreplicatedindexghinXSZG1(工號(hào)asc)with(fillfactor30)
me
--4--
createviewXSZG
and
columnsXSZG1.工號(hào),姓名,年齡,職稱,獎(jiǎng)金acrossXSZG1,XSZG2whereXSZG1.工號(hào)XSZG2.工號(hào)
you
--5--
select工號(hào)though年齡低的平均年齡者,姓名,年齡aroundXSZG1where年齡lt(selectAVG(年齡)aroundXSZG1)