{"id":36,"date":"2005-07-29T14:17:53","date_gmt":"2005-07-29T22:17:53","guid":{"rendered":"http:\/\/hongyu.org\/wordpress\/?p=36"},"modified":"2007-12-10T12:13:29","modified_gmt":"2007-12-10T20:13:29","slug":"create-oraclemysql-key-and-index","status":"publish","type":"post","link":"https:\/\/www.hongyu.org\/wordpress\/?p=36","title":{"rendered":"Create Oracle\/Mysql Key and Index"},"content":{"rendered":"<p>MySQL:<\/p>\n<p>create table user<br \/>\n(<br \/>\n    user_id int NOT NULL AUTO_INCREMENT,<br \/>\n    name varchar(100),<br \/>\n    phone varchar(100),<br \/>\n    email varchar(100),<br \/>\n    password varchar(100),<br \/>\n    role_id int,<br \/>\n    primary key(user_id),<br \/>\n    unique index email_idx(email),<br \/>\n    index role_idx(role_id)<br \/>\n);<\/p>\n<p>Oracle:<\/p>\n<p>create table user2<br \/>\n(<br \/>\n    user_id int NOT NULL,<br \/>\n    name varchar2(100),<br \/>\n    phone varchar2(100),<br \/>\n    email varchar2(100),<br \/>\n    password varchar2(100),<br \/>\n    role_id int,<br \/>\n    primary key(user_id),<br \/>\n    unique (phone),<br \/>\n    foreign key (role_id) references role(role_id)<br \/>\n);<br \/>\ncreate unique index cu on user2 (email);<br \/>\ncreate index role_idx on user2 (role_id);<\/p>\n<p>or<br \/>\n    create table foo (a int primary key,<br \/>\n                      b varchar(20) unique);<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL: create table user ( user_id int NOT NULL AUTO_INCREMENT, name varchar(100), phone varchar(100), email varchar(100), password varchar(100), role_id int, primary key(user_id), unique index email_idx(email), index role_idx(role_id) ); Oracle: create table user2 ( user_id int NOT NULL, name varchar2(100), phone varchar2(100), email varchar2(100), password varchar2(100), role_id int, primary key(user_id), unique (phone), foreign key (role_id) references &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.hongyu.org\/wordpress\/?p=36\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Create Oracle\/Mysql Key and Index&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/36"}],"collection":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=36"}],"version-history":[{"count":0,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/36\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}