mysql中key的用法 資料庫中KEY的用法

2021-10-18 12:13:45 字數 1187 閱讀 7538

下面這段**的最後,有一句【key`topicid`(`topic_id`)】代表什麼意思?它和primarykey、foreignkey、uniquekey有什麼區別?createtable`posts`(`id`int(11)notnullauto_increment,`...

下面這段**的最後,有一句【key `topicid` (`topic_id`)】代表什麼意思?它和primary key、foreign key、unique key有什麼區別?

create table `posts` (

`id` int(11) not null auto_increment,

`forumid` int(2) not null default '0',

`groupid` int(1) default '0',

`istopic` int(1) not null default '0',

`topic_id` int(8) not null default '0',

`title` varchar(100) default null,

`content` text,

`author` varchar(20) not null default '',

`author_id` int(8) not null default '0',

`click_times` int(7) default '0',

`reply_times` int(5) default '0',

`post_ip` varchar(16) default null,

`post_time` datetime default '0000-00-00 00:00:00',

`last_postor` varchar(20) default null,

`last_time` datetime default null,

`istop` int(3) not null default '0',

`islock` int(1) not null default '0',

`isdel` int(1) default '0',

primary key (`id`),

key `topicid` (`topic_id`)

) engine=myisam default charset=gbk;

展開

MySql 基本語法 資料庫操作

1.建立資料庫 增 語法形式 create database db name 資料庫選項 其中,資料庫選項主要有兩個 乙個是字符集,乙個是校對規則。每次建立乙個新的資料庫,都會在data目錄下建立乙個同名新目錄,在該目錄下,有乙個opt檔案 option 可以看到字符集和校對規則。mysql伺服器預...

mysql資料庫中標的key的含義

四種key primary key,unique key,key 和 foreign key。1.如果key是空的,那麼該列值的可以重複,表示該列沒有索引,或者是乙個非唯一的復合索引的非前導列 2.如果key是pri,那麼該列是主鍵的組成部分 3.如果key是uni,那麼該列是乙個唯一值索引的第一列...

MySql資料庫中Select用法小結

一 條件篩選 1 數字篩選 sql select from sheet1 where 銷售單價 100 2 字元條件 sql select from sheet1 where 物品名稱 擋泥板 3 日期條件 sql select from sheet1 where 物品名稱 擋泥板 4 區間條件 s...