create database emppless
on primary
(--建立資料庫
name = empitem,
size = 5mb,
filename ='f:\吳安學習\資料庫\資料庫練習\emppless.mdf',
filegrowth =20%
)log on
(name =empitem_log,
size =5mb,
filename ='f:\吳安學習\資料庫\資料庫練習\emppless_log.ldf',
filegrowth = 20%
)use emppless
create table departmenttable
(--自動id 部門 欄位名 型別 屬性
autoid int identity(1,1) primary key,
departmentname nvarchar(50)
)insert into departmenttable(departmentname)
values('總經辦')
insert into departmenttable(departmentname)
values('人事資源部')
insert into departmenttable(departmentname)
values('銷售部')
insert into departmenttable(departmentname)
values('研發部')
insert into departmenttable(departmentname)
values('採購部')
select * from departmenttable
--建立員工表
create table emptable
(--自動id 姓名 性別 年齡 身份證號碼 部門
autoid int identity(1,1) primary key,
name nvarchar(20) ,
gender nvarchar(1),
age int ,
identitycard nvarchar(5),
department int
)insert into emptable (name,gender,age,identitycard,department)
values('tom','男' ,30,'12345',1)
insert into emptable (name,gender,age,identitycard,department)
values('jack','男' ,30,'12356',2)
insert into emptable (name,gender,age,identitycard,department)
values('steve','男' ,30,'12356',2)
insert into emptable (name,gender,age,identitycard,department)
values('sk','女' ,30,'13456',2)
insert into emptable (name,gender,age,identitycard,department)
values('kun','男' ,30,'12456',3)
insert into emptable (name,gender,age,identitycard,department)
values('sn','男' ,30,'12356',3)
insert into emptable (name,gender,age,identitycard,department)
values('張三','男' ,30,'12356',3)
insert into emptable (name,gender,age,identitycard,department)
values('李四','女' ,30,'12456',3)
insert into emptable (name,gender,age,identitycard,department)
values('張四','男' ,30,'12346',3)
insert into emptable (name,gender,age,identitycard,department)
values('李五','女' ,30,'12346',4)
insert into emptable (name,gender,age,identitycard,department)
values('張六','男' ,30,'12356',4)
insert into emptable (name,gender,age,identitycard,department)
values('李為','女' ,30,'12345',5)
insert into emptable (name,gender,age,identitycard,department)
values('張七','男' ,30,'123456',5)
insert into emptable (name,gender,age,identitycard,department)
values('李七','女' ,30,'12346',5)
insert into emptable (name,gender,age,identitycard,department)
values('張y','男' ,33,'12456',5)
select * from emptable
update emptable set age =age+1 where gender=n'男' and age=30
select * from emptable
資料庫學習 insert into(批量新增)
資料新增insert命令有兩種形式 1 單一資料新增 inset into 表名 列名 列名 values 值 值 這種形式可以向資料庫中插入一條資料,也可以利用這種形式在資料庫中插入多條黃資料 inset into 表名 列名 列名 values 值 值 值 值 值 值 值 值 2 批量資料新增 ...
資料庫2之 庫的操作
1.資料庫的建立 語法 create database if no exists db name create specitification create specification create specification default character set charset name d...
知識分享之資料庫(2)
日期與時間型別 mysql提供的表示日期和時間的資料型別分別是 year date time datetime 和 timestamp。year型別 year型別用於表示年份,在mysql中,可以使用以下三種格式指定year型別 的值。1 使用4位字串或數字表示,範圍為 1901 2155 或190...