代码记录2

news/2025/1/13 6:22:16/

1
select year(replace(replace(replace('2013年10月21日','年','-'),'月','-'),'日',''))
2-1
create database question2 on primary(
Name='question2_data.mdf',
SIZE=6MB,
MAXSIZE=12MB,
fileNAME='D:\A1\question2_data.mdf',
FILEGROWTH=5%
)
log on(
NAME='question2_log.1df',
SIZE=6MB,
MAXSIZE=12MB,
FILENAME='D:\A1\question2_log.1df',
FILEGROWTH=10%
)
go

2-2
create table city(
CityCode char(4) not null primary key,
CityName Varchar(80) NOT NULL,
)
Create table category(
CategoryID int,
CategoryName varchar(50) NOT NULL,

)

2-2
alter table city add CitySurvey varchar(110)
2-3
alter table city alter column citysurvey varchar(100)
2-4
alter table city drop column citysurvey go
2-5
drop table city
drop table category
2-6
drop database question2

3-1
insert into city values('MSD','山东')

3-2
update publishers set Phone='0755-56556565' where PubCode='DGZC'
3-3
delete city where CityCode='MSD'
3-4
select * from titles order by CategoryID desc

3-5
select distinct categoryID from titles

3-6
select pubCode AS 出版社代码,pubName AS 出版社名称,Address AS 地址 from publishers where 
pubName='牡丹出版社'

4-1
select titleName,pubDate from titles where MONTH(PubDate) between 3and 6 
order by MONTH(pubDate) asc

4-2
select cityname,citycode from city where CityName in('沈阳','深圳','青岛')

4-3
select pubName,address from publishers where address like '%北京%'

4-4
select cityCode,cityname from city where CityCode like '_G%'

4-5
select titleName,2*price as '2倍的价格' from titles

4-6
select substring(titlename,1,6) as '前6位' from titles

4-7
select round(34.255,2) as '34.255',round(34.222,2) as '34.222'

4-8

select app_name() AS '当前应用程序名称'

5-1
select count(*) from city

5-2
select categoryID as '类别ID',COUNT(*) as '出版物数量' from titles group by categoryID

5-3
select categoryID as '类别ID',COUNT(*) as '出版物数量' from titles group by categoryID
having count(*)>2

5-4
select CategoryName,author,titlename from titles A JOIN category B on
A.CategoryID=B.CategoryID where categoryName like '%数据库%'

5-5
select titlename,Author,price from titles group by TitleName,Author,Price
Having price>(Select avg(price) from titles)

5-6
select * from city where cityCode='AGZ' union select * from city where CityCode='CSH'

6-1
declare @vaddr varchar(30),@vnum int set @vaddr='天河北路233号' set @vaddr=320

6-2
declare @vaddr varchar(30),@vnum int 
set @vaddr='天河北路233号'
set @vnum=320
print '局部变量:@vaddr:'+@vaddr+' @vnum:'+cast(@vnum as char(10))
print '全局变量:@@Language(当前所用语言的名称):'+@@Language

6-3
declare @code varchar(10),@price money
set @code='T007'
set @price=(select [price] from [titles] where [titleCode]=@code)
select * from titles
select @code+'出版物的价格是:'+cast(@price as varchar(6)) as 显示价格

6-4
create view view1(出版物名称,作者,价格,类别ID,出版日期)
as
 select titleName,Author,price,categoryID,pubDate from titles where year(pubDate) between 2010 and 2012

 select *from view1

6-5
CREATE VIEW view2(出版社代码,出版社名称,数量) 
 as
 select a.pubCode,pubName,count(B.PubCode)
 from publishers A left join titles B on A.PubCode=B.PubCode
 group by A.PubCode,PubName

 select * from view2

6-6
create index newidx on titles(pubCode)

6-7
 drop view view1,view2
 drop index newidx on titles

7-1
 create procedure sproc1 
 as select titleName,price 
 from titles where Author='斯考特'
 exec sproc1

7-2
 create procedure sproc2
 author char(10)
 as
 select titleName,price
 from titles where Author=@author 
 exec sproc2 '斯考特'

7-3
 create procedure sproc3
 (@code char(6),@name varchar(80) output)
 as
 set @name=(select titlename from titels where titleCode=@code)
 print @code+'的名称是:'+@name
 declare @t varchar(80)
 exec sproc3'T003',@t output

7-4
 create trigger newtrigger on titles
 after update as if(update(price)) print'出版物价格已更改,触发器起到作用'

 select * from titles update titles set price=34.50 where titleCode='T001'

7-5
 drop procedure sproc1,sproc2,sproc3
 drop trigger newtrigger

8-1
 sp_addLogin 'Login2','222222'
8-2
 exec  sp_grantDBaccess 'Login2','dbUser2'
8-3
grant select,insert, delete on publishers to dbUser2
 


http://www.ppmy.cn/news/819006.html

相关文章

扫雷游戏代码(升级版)

代码&#xff1a; #include<bits/stdc.h> #include<windows.h> #include<conio.h> using namespace std; int x,y,l,l2; bool s,c[12][12],flag; char a[12][12],b[12][12],f; int statistics_1(int j,int i); int statistics_2(int j,int i); void around(…

【CE入门教程】使用Cheat Engine(CE)修改游戏“植物大战僵尸”之僵尸篇

目录 1.寻找僵尸位置基址 2.实现“秒杀”僵尸&#xff08;修改僵尸血量&#xff09; 上一期教程中&#xff0c;我们学习了修改植物大战僵尸的单卡片无CD、全卡片无CD、豌豆射手射速修改以及实现豌豆射手发射“玉米加农炮”。PS&#xff1a;上篇链接&#xff1a;【CE入门教程】…

使用Cheat Enginee(CE)找到“植物大战僵尸”金币的内存基址

使用Cheat Enginee(CE)找到“植物大战僵尸”金币的内存基址 在ce中首次扫描当前金币数的十分之一&#xff0c;捡金币后再次扫描当前金币数的十分之一。 双击添加到地址列表&#xff0c;修改数值后金币数值随之改变。 查看谁改写了这个地址 双击打开&#xff0c; 可以看出…

【杂项】 Cheat Engine抓游戏基址

记录一下CE偏移抓游戏数据基址的过程吧…… 一、说明二、操作1&#xff09;首先手动抓数据2&#xff09;接下来建立指针3&#xff09;然后建立第二个指针3&#xff09;保存与使用脚本 一、说明 CE(Cheat Engine)是一个强大的游戏修改器&#xff0c;可以读取和写入游戏数据。在…

植物大战僵尸源代码

最近下了植物大战僵尸的代码,却发现我什么也看不懂,呜呼哀哉。 分析数据: 游戏基址:6a9ec0 768阳光: 5560 768 6a9ec0 最多几个植物:6a9ec0 768 144 24准备了几个植物:d24 774 6a9ec0僵尸行走:52AFCA486C55 获取怪物:413108 ebx:6a9ec0 768 怪物属性偏移:+2C X坐标+30 Y…

【CE入门教程】使用Cheat Engine(CE)修改游戏“植物大战僵尸”之植物篇

目录 1.单卡片无CD 1.1 思路一 1.2 思路二 2.全卡片无CD 3.豌豆射手射速修改&#xff08;修改植物射速&#xff09; 4.实现豌豆射手发射“玉米加农炮”&#xff08;思路&#xff09; 上一期教程中&#xff0c;我们学习了修改植物大战僵尸的阳光数量、向日葵生产阳光速率以…

epic显示游戏服务器离线,无主之地3Epic离线如何进入游戏 想要Epic离线一键进入游戏就这么做...

目前有很多的网友都已经下载安装了最新的无主之地3PC版游戏&#xff0c;但是这款游戏是需要Epic平台启动的&#xff0c;所以就必须联网&#xff0c;那么有什么方法可以3Epic离线进入游戏吗?方法当然是有的&#xff0c;下面就赶紧跟随小编一起来看看操作的方法吧。 无主之地3Ep…

CE修改器入门:运用代码注入

从本关开始&#xff0c;各位会初步接触到CE的反汇编功能&#xff0c;这也是CE最强大的功能之一。在第6关的时候我们说到指针的找法&#xff0c;用基址定位动态地址。但这一关不用指针也可以进行修改&#xff0c;即使对方是动态地址&#xff0c;且功能更加强大。 代码注入是将一…