MySQL建立企業資訊表 mysql建立表和資料庫

2021-10-17 22:53:10 字數 1945 閱讀 1953

1.建立資料庫:    建立的**:create  資料庫的**:database   資料庫表名:隨便起,只要自己記住就行。test

create database test;

2.刪除資料庫: 刪除的**:drop  資料庫**:database  要刪除哪乙個資料庫:資料庫名:test

drop database test;

3.建立表:   資料庫建好後該往裡建立表了;例下  建立: create   表的**: table   表名:隨便取   ceshi

create table class

code varchar(20) primary key,

name varchar(20) not null

create table ceshi

ids int auto_increment primary key,

uid varchar(20),

name varchar(20),

class varchar(20),

foreign key (class) references class(code)

注:自增長**代表:auto_increment

主建的**代表:primary key

外來鍵的**代表公式:foreign key (列名)  references  主表名 (列名)

fornign key+(列名)  代表給哪乙個加外來鍵 references 要引用哪個表裡的列

是否為空: 不為空的**:not null

4.刪除:      刪除**的代表:drop  刪除的是表: table  要刪的那個表名:ceshi

drop table ceshi;

**寫建立資料庫是注意:

1.型別包含長度的,在型別後面加(括號),括號裡面寫長度

2.上一列寫完加逗號

3.最後一列不要寫逗號

4.在每一條sql語句寫完之後要加分號;

5.如果有外來鍵關係,先建立主表

例子:建立表:

create table class

code varchar(20) primary key,

name varchar(20)

create table student

code varchar(20) primary key,

name varchar(20),

*** bit,

age int,

class varchar(20),

foreign key (class) references class(code)

create table kecheng

code varchar(20) primary key,

name varchar(20)

create table teacher

code varchar(20) primary key,

name varchar(20)

create table chengji

ids int auto_increment primary key,

scode varchar(20),

kcode varchar(20),

degree float,

foreign key (scode) references student(code),

foreign key (kcode) references kecheng(code)

create table tkecheng

ids int auto_increment primary key,

tcode varchar(20),

kcode varchar(20),

foreign key (kcode) references kecheng(code),

foreign key (tcode) references teacher(code)

mysql表檔案建立 php檔案建立mysql的表

乙個php檔案,裡面內容是建表語句,如下,怎麼操作這個php檔案才能在mysql中建表啊?createtableifnotexists category id.乙個php檔案,裡面內容是建表語句,如下,怎麼操作這個php檔案才能在mysql中建表啊?create table if not exist...

企業資訊化

要清晰地理解和掌握企業資訊化規劃的概念,我們需要首先認識什麼是企業資訊化。所謂企業資訊化,就是企業將資訊科技手段應用到企業的生產和運營管理中,利用資訊科技來改造和提公升自己管理水平的過程,在這一過程中,企業挖掘先進的管理理念,通過先進的資訊科技和管理手段去整合企業現有的生產 經營 設計 製造 管理和...

PDM與企業資訊整合

一 企業對pdm的需求 目前,廣大cad使用者一方面從cad等技術的推廣應用中明顯地提高了設計能力和圖紙質量,特別是採用三維模型設計 有限元分析驗證 機構運動 等手段 大大地減少了差錯 提高了設計質量 降低了返工率 另一方面,由於cad技術的全面推廣,一系列問題又擺在了企業的面前。1.資料管理 過去...