12-1 上午mysql 基本語句

來源:互聯網
上載者:User

標籤:ref   tab   ima   code   name   修改   ble   key   char   

create table test
(
code varchar(20) primary key,
name varchar(20)
);

關鍵字
primary key 主鍵
非空 not null
foreign key(列名)references 主表名(列名) 外鍵
聯合主鍵(表找不到主鍵)
自增長列 auto_increment(表找不到主鍵)
注意:1.每條語句後加分號,2.最後一列不加逗號3.符號要是中文的

create table test
(
code varchar(20) primary key,
name varchar(20) not null
);

create table zhu
(
code int(20) primary key,
name varchar(20)
);

create table cong
(
code int(20) primary key,
name varchar(20),
zhu int,
foreign key (zhu) references zhu(code)
);


create table haoyou
(
ids int auto_increment primary key,
me varchar(20),
friends varchar(20)

)

作業
1.修改表語句
二 對資料得增刪改查CRUD
增加資料:
insert into 表名 values(‘‘,‘‘);
insert into 表名(列名) values(‘‘);
注意:1.如果添加 得資料是字串,需要加‘‘,其他類型不要加。
2.添加資料得時候值得數量要和列數量匹配
3. 單獨增加一條資料 insert into 表名(列名) values(‘‘);
4.如果要添加得列是自增長列可以給空值

12-1 上午mysql 基本語句

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.