SQL 10 函数 准备——建表

SQL中可供使用的函数是非常多的,这些函数的功能包括

1. 转化字符串大小写

2. 求一个数的对数

3. 计算两个日期之间的天数间隔等

熟练掌握这些函数将能帮助我们更快地完成业务功能。

创建数据表的SQL语句:

MySQL:

CREATE TABLE T_Person(

  FIdNumber VARCHAR(20),

  FName VARCHAR(20),

  FBirthday DATETIME,

  FRegDay DATETIME,

  FWeight DECIMAL(10, 2)

)

 

Oracle:

CREATE TABLE T_Person(

  FIdNumber VARCHAR(20),

  FName VARCHAR(20),

  FBirthday DATE,

  FRegDay DATE,

  FWeight NUMBERIC(10,2)

)

 

插入初始数据:

MySQL:

INSERT INTO T_Person(FIdNumber, FName, FBirthday, FRegday, FWeight) VALUES('123456789120', 'Tom', '1981-03-22', '1998-05-01', 56.67)

INSERT INTO T_Person(FIdNumber, FName, FBirthday, FRegday, FWeight) VALUES('123456789121', 'Jim', '1981-03-22', '1998-05-01', 36.17)

INSERT INTO T_Person(FIdNumber, FName, FBirthday, FRegday, FWeight) VALUES('123456789122', 'Tom', '1981-03-22', '1999-08-21', 40.33)

INSERT INTO T_Person(FIdNumber, FName, FBirthday, FRegday, FWeight) VALUES('123456789123', 'Tom', '1981-03-22', '2001-09-18', 46.23)

INSERT INTO T_Person(FIdNumber, FName, FBirthday, FRegday, FWeight) VALUES('123456789124', 'Tom', '1981-03-22', '2000-03-01', 48.68)

INSERT INTO T_Person(FIdNumber, FName, FBirthday, FRegday, FWeight) VALUES('123456789125', 'Tom', '1981-03-22', '1998-05-01', 66.67)

INSERT INTO T_Person(FIdNumber, FName, FBirthday, FRegday, FWeight) VALUES('123456789126', 'Tom', '1981-03-22', '1998-05-01', 51.28)

INSERT INTO T_Person(FIdNumber, FName, FBirthday, FRegday, FWeight) VALUES('123456789127', 'Tom', '1981-03-22', '1998-05-01', 60.32)

 

Oracle:

INSERT INTO T_Person(FIdNumber, FName, FBirthday, FRegday, FWeight) VALUES('123456789127', 'Tom', TODATE('1981-03-22', 'YYYY-MM-DD HH24:MI:SS'), TODATE('1998-05-01','YYYY-MM-DD HH24:MI:SS'), 60.32)

INSERT INTO T_Person(FIdNumber, FName, FBirthday, FRegday, FWeight) VALUES('123456789127', 'Tom', TODATE('1981-03-22', 'YYYY-MM-DD HH24:MI:SS'), TODATE('1998-05-01','YYYY-MM-DD HH24:MI:SS'), 60.32)

INSERT INTO T_Person(FIdNumber, FName, FBirthday, FRegday, FWeight) VALUES('123456789127', 'Tom', TODATE('1981-03-22', 'YYYY-MM-DD HH24:MI:SS'), TODATE('1998-05-01','YYYY-MM-DD HH24:MI:SS'), 60.32)

INSERT INTO T_Person(FIdNumber, FName, FBirthday, FRegday, FWeight) VALUES('123456789127', 'Tom', TODATE('1981-03-22', 'YYYY-MM-DD HH24:MI:SS'), TODATE('1998-05-01','YYYY-MM-DD HH24:MI:SS'), 60.32)

INSERT INTO T_Person(FIdNumber, FName, FBirthday, FRegday, FWeight) VALUES('123456789127', 'Tom', TODATE('1981-03-22', 'YYYY-MM-DD HH24:MI:SS'), TODATE('1998-05-01','YYYY-MM-DD HH24:MI:SS'), 60.32)

INSERT INTO T_Person(FIdNumber, FName, FBirthday, FRegday, FWeight) VALUES('123456789127', 'Tom', TODATE('1981-03-22', 'YYYY-MM-DD HH24:MI:SS'), TODATE('1998-05-01','YYYY-MM-DD HH24:MI:SS'), 60.32)

INSERT INTO T_Person(FIdNumber, FName, FBirthday, FRegday, FWeight) VALUES('123456789127', 'Tom', TODATE('1981-03-22', 'YYYY-MM-DD HH24:MI:SS'), TODATE('1998-05-01','YYYY-MM-DD HH24:MI:SS'), 60.32)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值