SQL Server 建立 修改 刪除資料表

2022-09-12 17:00:22 字數 1065 閱讀 4506

1. 圖形介面方式運算元據表

(1)建立和修改資料表

列名中如果有兩個以上單詞時,最好用下劃線連線,否則可能會給將來的查詢維護帶來不便。我們公司美國佬做的資料庫就很煩,所有列名都有空格,一旦忘記用方括號就gg了。

(2)刪除資料表

2. transect-sql 語句運算元據表

(1)建立和修改資料表

use howie

create table customers          --建立資料表

(customer_number varchar(20) not null,  --列名 資料型別(字元長度) 不允許空值

customer_name varchar(100) null    --列名 資料型別(字元長度) 允許空值(如果不設定則預設為null))go

alter table customers           --修改資料表

add primary key(customer_number)    --將customer_number設為主鍵

goalter table customers

add address varchar(100)        --新增列

goalter table customers

alter column customer_name nvarchar(100)  --更改資料型別

go(2) 刪除資料表

drop

table customers            --刪除資料表

建立 修改 刪除表

1 建立表 1.1 完整約束條件表 約束條件 說明primary key 表示該屬性為表的主鍵,可以唯一的表示對應的元組 foreign key 標示該屬性為表的外來鍵,是與之聯絡的某錶的主鍵 not null 標示該屬性不能為空 unique 標示該屬性的值是唯一的 auto increment ...

SQL建立 修改 刪除表

建立表 create table 表名 列名 資料型別 屬性 列名 資料型別 屬性 增加表的列 alter table 表名 add 欄位名 資料型別 屬性 修改表的列 alter table 表名 modify column 欄位名 資料型別 屬性 刪除表的列 alter table 表名 dro...

Oracle(建立 修改 刪除表)

根據rowid獲取某一元組 2 表的建立 1 方式一 create table 2 方式二 當as後面的語句能夠查詢到資料的時候,不僅建立了表的結構而且查詢到的資料也會自動新增到新建立的表內部 查詢表中是否有資料 當as後面的語句不能查詢到資料的時候,只建立表的結構,不會向表中新增資料 3 修改表 ...