第四章 C++简洁的数据库(一)

第四章 C++简洁的数据库(一)

第四章 C++简洁的数据库(一)(原文链接)

哈喽,大家好,我叫人宅,很高兴和大家分享一下关于基础数据库。

UE4中有自带的数据库(DataTable),支持读取.CSV文件也可以读取Json,都可以建立一套增查减改的接口,如果表一多,像多表联查,效率可能会有所下降,如果是搭建一套自己的服务器, 建议推荐MySql,它支持多种语言,在这里只我们会用C++来展示相关功能的基本运用:”


*Modify_Mat_List 表的名字

*VALUES 值

基本表(表)

数据插入一行

INSERT INTO Modify_Mat_List (id) VALUES (111);

插入指定test下Modify_Mat_List表内的id`, `MatName`, `name` 的值 为'222223',

'sdfsfsf', NULL

INSERT INTO `test`.`Modify_Mat_List` (`id`, `MatName`, `name`) VALUES ('222223',
'sdfsfsf', NULL);

扫描二维码关注公众号,回复: 4940386 查看本文章

查询id = 22一行

选择 id 和matname的数据,提取id = 22的数据

SELECT
id,MatName FROM Modify_Mat_List WHERE id = 22 ;

查一列

select 列名 from tablexxx SELECT MatName FROM `Modify_Mat_List`;

插入一列 加一个名字叫Name的列表头

alter table T2 add name varchar(30);

查询全表

SELECT *FROM `Modify_Mat_List`;

替换

update Modify_Mat_List set id = REPLACE(id, '22', '123');

修改某个值对应的id

update Modify_Mat_List set name = "4122" where id= 1;

删除一行

delete from Modify_Mat_List where ModifyID = '4';

删除一列

alter table Modify_Mat_List drop column ww ;

把一列名eee改为unit

alter table Modify_Mat_List change eee unit char;

创建一个表T让后将选择Modify_Ref_List的数据进行拷贝

复制table表create table 新表名(select ID,name,number,numberidfrom 要复制的表名);

create table T(select RefObjectID,RefMatID,RefMatIndex from Modify_Ref_List);

修改一行的数据

update Modify_Mat_List set ScalarParameter = "sdasd",TextureParameter ="wdasd" ,VectorParameter = "asdaf"where ModifyID = 2;

选中RefObjectID = 2中所有数据

select *from Modify_Ref_List where RefObjectID = 2;

选中RefObjectID = 2下所有RefComponentID 的数据

select RefComponentID from Modify_Ref_List where RefObjectID = 2;

以上是关于我们Sql的基础功能;

如果对游戏开发感兴趣,可以看看我以前的文章:

人宅:UE4C++独立游戏开发-守护神石​zhuanlan.zhihu.com

猜你喜欢

转载自blog.csdn.net/qq_23369807/article/details/82108841