varchar

Does InnoDB have static tables?

百般思念 提交于 2020-06-17 03:36:06
问题 I was reading MySQL documentation and I was wondering whether MyISAM's "static" table format also applies on InnoDB or not? Do I gain performance, if I use CHAR instead of VARCHAR when the real lengths varies between 0 and 100 characters or is using VARCHAR(100) better? 回答1: InnoDB does have fixed-width rows and there can be some advantage to declaring all columns in a table as fixed-width. The main benefit is that all "holes" in a page can be reused for any insertion, since all rows are the

Unable to convert varchar to array in Presto Athena

╄→гoц情女王★ 提交于 2020-06-12 08:59:11
问题 My data is in varchar format. I want to split both the elements of this array so that I can then extract a key value from the json. Data format: [ { "skuId": "5bc87ae20d298a283c297ca1", "unitPrice": 0, "id": "5bc87ae20d298a283c297ca1", "quantity": "1" }, { "skuId": "182784738484wefhdchs4848", "unitPrice": 50, "id": "5bc87ae20d298a283c297ca1", "quantity": "4" }, ] For e.g. I want to extract skuid from the above column. So my data after extraction should look like: 1 5bc87ae20d298a283c297ca1 2

Why specify a length for character varying types

╄→гoц情女王★ 提交于 2020-05-25 11:31:27
问题 Referring to the Postgres Documentation on Character Types, I am unclear on the point of specifying a length for character varying (varchar) types. Assumption: the length of string doesn't matter to the application. you don't care that someone puts that maximum size in the database you have unlimited hard disk space It does mention: The storage requirement for a short string (up to 126 bytes) is 1 byte plus the actual string, which includes the space padding in the case of character. Longer

Best datatype to store hexidecimal and hex characters in the database

99封情书 提交于 2020-05-15 00:56:37
问题 I'm using the Ethereum api. I want to store the information from the api into a mysql table. The address data looks like: 0x3f5ce5fbfe3e9af3971dd833d26ba9b5c936f0be 0x1d80982502f3bb75654df13aa32bbd5ac9cab7d6 0xaf13bbdbe1ff53c2df7109a53c217320d2d76ee2 ... I've been using just varchar column for these characters. Are there a better data type? I'm thinking maybe varbinary but I don't know if there's any advantages. The disadvantage is that the sql code will be messier as I will have to HEX() and

SQL Setting Variable for Current Year Month by Combining two VarChar fields using case statement

ぃ、小莉子 提交于 2020-04-18 05:18:00
问题 I am trying to declare a variable for the current year and month based on a field called YEARMO. It's a 6 character varchar field with the first 4 characters representing the year and the next 2 characters representing the month (ex. February 2018 as 201802). I need the month variable to have a 0 in front of it if is a month that only has one digit (any month before October). Current code returns '20182' and would like it to return '201802'. declare @current_month varchar(6) set @current

PHP MySQL 创建数据表

与世无争的帅哥 提交于 2020-04-08 13:56:55
PHP 创建 MySQL 表 一个数据表有一个唯一名称,并有行和列组成。 使用 MySQLi 和 PDO 创建 MySQL 表 CREATE TABLE 语句用于创建 MySQL 表。 我们将创建一个名为 "MyGuests" 的表,有 5 个列: "id", "firstname", "lastname", "email" 和 "reg_date": CREATE TABLE MyGuests ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, email VARCHAR(50), reg_date TIMESTAMP ) 上表中的注意事项: 数据类型指定列可以存储什么类型的数据。完整的数据类型请参考我们的 数据类型参考手册 。 在设置了数据类型后,你可以为每个列指定其他选项的属性: NOT NULL - 每一行都必须含有值(不能为空),null 值是不允许的。 DEFAULT value - 设置默认值 UNSIGNED - 使用无符号数值类型,0 及正数 AUTO INCREMENT - 设置 MySQL 字段的值在新增记录时每次自动增长 1 PRIMARY KEY - 设置数据表中每条记录的唯一标识。

无法像程序语言那样写SQL查询语句,提示“数据库中已存在名为 '#temp1' 的对象。”

夙愿已清 提交于 2020-04-06 23:11:14
if exists( select exp_count from tbl_expend where exp_valid = 1 and exp_public = 0 and exp_monthly = 0 and convert(varchar(7),exp_date,120) = convert(varchar(7),cast('2020/04/03 22:57:20'as datetime ),120) ) begin select exp_count into #temp1 from tbl_expend where exp_valid = 1 and exp_public = 0 and exp_monthly = 0 and convert(varchar(7),exp_date,120) = convert(varchar(7),cast('2020/04/03 22:57:20'as datetime ),120) end else begin select 0 as exp_count into #temp1 end 来源: https://www.cnblogs.com/bamboo-140/p/12649933.html

基于 Serverless 的人工智能相册小程序

吃可爱长大的小学妹 提交于 2020-04-06 00:22:50
日常生活中,我们常常会想要「搜索照片」。每当寻找很久远的照片时,记忆模糊,检索照片时只能想起大致的时间,然后一张张查看。这样不仅效率低下,还经常会漏掉我们想找的照片。 近几年微信小程序发展迅速,如果有这么一款软件,我们只需要用文字简单描述,就能实现图片的快速检索,岂不是很棒! 本项目将以小程序为例,在 Serverless 架构上进行开发。该小程序在保留相册基础功能(新建相册、删除相册、上传图片、查看图片、删除图片)上,增加人工智能搜索 —— 即用户上传图片之后,基于 Image Caption 技术,自动对图片进行描述,实现 Image to Text 的过程。这样,当用户进行搜索时,通过文本间的相似度,就可以返回最贴近的图片。 基础设计 该项目设计主要拥有登录、相册、图片上传和预览功能,以及搜索功能。如图所示: 注册功能的主要作用是:通过获取用户的唯一 id(微信中的 OpenId),来将用户信息存储到数据库中,之后的所有操作,都需要以该 id 作为区分; 相册功能主要包括相册的增删查改等功能; 图片功能包括图片上传、删除和查看; 搜索功能主要是可以查看指定标签对应的图片列表,以及指定搜索内容对应的列表。 当然这四个主要功能和模块是和前端关系紧密的部分,除此之外还有后端异步操作的两个模块,分别是图像压缩和图像描述功能。 1. 注册功能: 注册功能是用户点击注册账号之后

获取格式字符串第idx个值及实例

混江龙づ霸主 提交于 2020-04-04 01:49:58
--根据索引idx值获取格式串中第idx个值 如数据'11,12,13,14,15,16' 方法:格式串+分隔符;@str='11,12,13,14,15,16'+',' select dbo.GetStrByindex('11,12,13,14,15,16,', ',', 3); -- 13 create function [dbo].[GetStrByindex](@str varchar(8000),@split varchar(10),@idx int) --@str:待查找字符串 returns varchar(100)   as begin declare @inx int set @inx=0 WHILE(CHARINDEX(@split,@str)<>0) begin   SET @INX=@INX+1   if @inx=@idx   --第一个@split之前的字符串   return SUBSTRING(@str,1,CHARINDEX(@split,@str)-1)   --将第一个@split后面的字符串重新赋给@str   SET @str=STUFF(@str,1,CHARINDEX(@split,@str),'') end return ''; end GO 此过程可能在数据维护时,偶尔会遇到。 /* 参数1:@Type 整型 0:新增1:修改2

Phoenix + HBase,让你像操作MySQL一样操作HBase

别来无恙 提交于 2020-04-02 06:06:21
Phoenix关联HBase的操作(三种情况) 情况一:Hbase已经有已存在的表了,可在Phoenix中创建对应的视图,视图只能做查询操作,不能做增删改 hbase中已创建表且有数据,表名:phoenix 在phoenix中创建对应视图 create view "phoenix"( pk varchar primary key, "info"."name" varchar, "info"."age" varchar ); 查询视图数据 情况二:Hbase已存在表,可在Phoenix中创建对应的表,对表的操作可读可写,意味着可以对Hbase的表进行插入查询,删除操作。 hbase中已存在表并且有数据 在phoenix中创建对应的表 create table "t_person"( id VARCHAR PRIMARY KEY, "f"."id" VARCHAR, "f"."name" VARCHAR, "f"."age" VARCHAR ) column_encoded_bytes=0; 在phoenix中查询数据 在phoenix中插入数据 此时查看hbase中对应的t_person表数据 情况三:Hbase没有表;可直接在Phoeinx中创建表,对应的Habse中也会自动建表,在Phoenix中对表操作就是直接对Hbase中的表进行操作。 在phoenix中直接建表,t