create
table
[表名]
( 欄位名 資料型別 [
notnull][
primary
key]
, 欄位名 資料型別 [
notnull][
primary
key]
)
alter
table
[table_global_system_basic_module_yogurtcry_20201007]
adddefault(-
1)for datastate
exec sp_addextendedproperty 'ms_description'
,'需要新增的說明'
,'user'
, dbo,
'table'
,[表名]
,'column'
,[列名]
insert
into
[表名]
( 欄位名1
, 欄位名2
, 欄位名3
, 欄位名4
)select
'要插入的資料1'
,'要插入的資料2'
,'要插入的資料3'
,'要插入的資料4'
where
notexists
(select
欄位名1
, 欄位名2
, 欄位名3
, 欄位名4
from
[表名]
where
[表名]
.要比對的欄位名 =
'要比對的資料'
);
alter
table
[表名]
addconstraint
[約束名]
unique
(欄位名)
alter
table
[表名]
drop
constraint
[約束名]
select
table_tablenamelist.name as 表名,
table_tablerowcount.
rows
as 表內行數
from
(select
name,
id,xtype
from sysobjects
where sysobjects.xtype =
'u')
as table_tablenamelist
left
join
(select
id,rows
from sysindexes
where indid in(0
,1))
as table_tablerowcount on table_tablenamelist.id = table_tablerowcount.id
order
by 表名 asc
, 表內行數 desc
select
table_tablerowcountinfo.name as 表名,
table_columnname.column_name as 欄位名,
table_tablerowcountinfo.
rows
as 表內行數
from
(select
table_tablenamelist.name,
table_tablerowcount.
rows
from
(select
name,
id,xtype
from sysobjects
where sysobjects.xtype =
'u')
as table_tablenamelist
left
join
(select
id,rows
from sysindexes
where indid in(0
,1))
as table_tablerowcount on table_tablenamelist.id = table_tablerowcount.id
)as table_tablerowcountinfo
left
join
(select
*from information_schema.
columns
)as table_columnname on table_columnname.table_name = table_tablerowcountinfo.name
mysql常用語句 MySQL常用語句
create table student id int primary key auto increment comment 學號 name varchar 200 comment 姓名 age int comment 年齡 comment 學生資訊 修改表注釋 alter table studen...
php mysql 常用語句 mysql常用語句
一 修改mysql使用者密碼 mysql h localhost u root p 命令列登入 update user set password password 123456 where user root 二 資料庫操作 show databases 顯示資料庫 create database ...
sql常用語句
use myoa select from delete from department where departmentid 1 insert department departmentid,departmentname values 1,技術部 update department set depa...