简体   繁体   English

使用 TEXT 列创建 MySql 数据库

[英]Create MySql database with TEXT column

I'm creating MySql database table from C# desktop application on remote server.我正在从远程服务器上的 C# 桌面应用程序创建 MySql 数据库表。 I would like to make long records for columns content.我想为列内容做长记录。 I guess TEXT type must be suitable for this, but I'm not sure, how to set it from my createTableQuery string, instead varchar(120) :我猜 TEXT 类型必须适用于此,但我不确定如何从我的createTableQuery字符串中设置它,而不是varchar(120)

string createTableQuery = string.Format(@"CREATE TABLE `{0}` (
   `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
   `slots` varchar(120) NOT NULL DEFAULT '',
   `vectors` varchar(120) NOT NULL DEFAULT '',
   PRIMARY KEY (`id`),
   KEY `id` (`id`)) 
   ENGINE = MyISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8;", "tab");

Or maybe I should use some different type...或者也许我应该使用一些不同的类型......

Any advice and example would be useful任何建议和例子都会有用

It would be:这将是:

string createTableQuery = string.Format(@"CREATE TABLE `{0}` (
`id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`slots` TEXT NOT NULL DEFAULT '',
`vectors` TEXT NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `id` (`id`)) 
ENGINE = MyISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8;", "tab");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM