---
# System prepended metadata

title: ERP 後端文件

---

# ERP 後端文件


## 修訂歷史

| 日期       | 版本 | 修訂描述 | 作者 |
| ---------- | ---- | ------- | ---- |
| 2022/09/28 | V1.0 | SQL語法  | 立婷 |
| 2022/09/28 | v1.0 | SQL語法  | 士凱 |

##  SQL語法

### 建立資料庫
```sql=
CREATE DATABASE TestData  
GO

USE TestData  
GO
```

#### emp_info
```sql=
CREATE TABLE emp_info (
    emp_id        VARCHAR(14) NOT NULL,
    name          VARCHAR(50) NOT NULL,
    location_name VARCHAR(50),
    tel           VARCHAR(13),
    mail          VARCHAR(100),
    dept          VARCHAR(50),
    PRIMARY KEY(emp_id)
);
```
#### area
```sql=
CREATE TABLE area (
    area_id       INT         AUTO_INCREMENT,
    location_name VARCHAR(50) NOT NULL,
    city          INT,
    discript      VARCHAR(10),
    road          VARCHAR(100),
    z_code        INT,
    scope         INT,
    PRIMARY KEY(area_id, z_code)
);
```

#### record
```sql=
CREATE TABLE record (
	rec_id		    int PRIMARY KEY NOT NULL,  
	date_time	    date,  
	id		    varchar(14),  
	punch_in	    time(7),
	punch_out	    time(7),
	overtime_in	    time(7),
	overtime_out	    time(7),
);
GO
```

#### att_set
```sql=
CREATE TABLE att_set (
    att_id		    int PRIMARY KEY NOT NULL,  
    dept	            varchar(50),  
    punch_in		    time(7),
    punch_out		    time(7),
    punch_in_notice	    varchar(1),
    punch_out_notice	    varchar(1),
    punch_in_err	    varchar(1),
    punch_out_err	    varchar(13),
    weekdays		    varchar(50),
    remark		    varchar(100),
);
GO
```

### 建立出來的table