LoginSignup
0
0

More than 3 years have passed since last update.

僕のSQLserver

Last updated at Posted at 2020-01-16

自分の忘れやすい操作を自分用にメモ

テーブルの構造的な操作

--列の削除
ALTER TABLE [table] DROP COLUMN [column]

-- NOT NULL 制約の追加
ALTER TABLE [table] ALTER COLUMN [column] [date_type] NOT NULL

--primarykeyの設定
ALTER TABLE [table] ADD PRIMARY KEY ([column_x],[column_y]...)

--primarykeyの設定解除
ALTER TABLE [table] DROP CONSTRAINT [PRIMARY KEY name]

更新

特定の列の更新
UPDATE [table] SET [column] = [alter value]

挿入

BULK INSERT
BULK INSERT [table_name]
FROM 'file_path'
WITH (FIRSTROW = 2, FIELDTERMINATOR = ',')

関数

--文字の置換--
REPLACE(対象,検索文字,置換文字)

--値の判定(数値かの判定)--
isnNumeric(x)
    --数値の場合:1
    --数値でない場合:0
OVER

OVER

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0