數(shù)據(jù)庫(kù)怎么用代碼創(chuàng)建數(shù)據(jù)庫(kù)表 mysql運(yùn)行sql文件后會(huì)創(chuàng)建表嗎?
mysql運(yùn)行sql文件后會(huì)創(chuàng)建表嗎?這個(gè)不需要看sql文件的語(yǔ)法如何確定符合國(guó)家規(guī)定MySQL數(shù)據(jù)庫(kù)規(guī)范,你不能不能拎著Oracle數(shù)據(jù)庫(kù)腳本裝在MySQL里面執(zhí)行,那豈不是很尷尬!其實(shí)了,如果沒(méi)有
mysql運(yùn)行sql文件后會(huì)創(chuàng)建表嗎?
這個(gè)不需要看sql文件的語(yǔ)法如何確定符合國(guó)家規(guī)定MySQL數(shù)據(jù)庫(kù)規(guī)范,你不能不能拎著Oracle數(shù)據(jù)庫(kù)腳本裝在MySQL里面執(zhí)行,那豈不是很尷尬!
其實(shí)了,如果沒(méi)有語(yǔ)確符合國(guó)家規(guī)定MySQL規(guī)范,那也得看里面是否需要有類(lèi)似createtable的語(yǔ)句代碼!
sql怎么添加一個(gè)新列?
先添加一個(gè)新的列表方法萬(wàn)分感謝:
使用SQL語(yǔ)句為數(shù)據(jù)表增加一個(gè)字段,在用altertable子句。語(yǔ)法:altertable表格名main字段名。數(shù)據(jù)類(lèi)型-altertabletable_namesetcol_namechar(5)。
使用Transact-SQL創(chuàng)建數(shù)據(jù)庫(kù)的步驟有分急求?
代碼示例:
-1--
create database test2 on(nametest2_dat,,size3MB,maxsize9MB,filegrowth8%)
logoff(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--
renameoutsideXSZG1
select1001,李小新,男,已婚,33,1800union
select1002,趙小蕊,女,沒(méi)結(jié)婚,28,2200union
select1003,錢(qián)學(xué)塘zhi,男,已婚,45,3500union
select1004,李明啟,男,已婚,56,5500union
select1005,肖小風(fēng),女,未婚未育,27,1800union
select1006,黃興民dao,男,已婚,46,3300
--2.3--
createtableXSZG2(工號(hào)char(4),職稱(chēng)char(12),獎(jiǎng)金int)
--2.4--
renamearoundXSZG2
select1001,普通員工,300 unionselect 1002,技師,600union
select1003,工程師,800union
select1004,高級(jí)技師,1400union
select1005,工程師,800union
select1006,技師,600
--3--
createpartitionedindexghinXSZG1(工號(hào)asc)with(fillfactor30)
play
--4--
createviewXSZG
such
columnsXSZG1.工號(hào),姓名,年齡,職稱(chēng),獎(jiǎng)金outsideXSZG1,XSZG2whereXSZG1.工號(hào)XSZG2.工號(hào)
go
--5--
select工號(hào)though年齡高于平均年齡者,姓名,年齡aroundXSZG1where年齡lt(selectAVG(年齡)returningXSZG1)