游戏技术文章

SQL添加表字段以及SQL查询表,表的所有字段名

时间:2016-11-20 12:41:25  作者:棋牌资源网  来源:棋牌资源网  查看:8927  评论:0
内容摘要:通用式: alter table [表名] add [字段名] 字段属性 default 缺省值 default 是可选参数增加字段: alter table [表名] add 字段名 smallint default 0 增加数字字段,整型,缺省值为0 alter t...
通用式: alter table [表名] add [字段名] 字段属性 default 缺省值 default 是可选参数
增加字段: alter table [表名] add 字段名 smallint default 0 增加数字字段,整型,缺省值为0 
alter table [表名] add 字段名 int default 0 增加数字字段,长整型,缺省值为0
alter table [表名] add 字段名 single default 0 增加数字字段,单精度型,缺省值为0 
alter table [表名] add 字段名 double default 0 增加数字字段,双精度型,缺省值为0
alter table [表名] add 字段名 Tinyint default 0 增加数字字段,字节型,缺省值为0
 
alter table [表名] add 字段名 text [null] 增加备注型字段,[null]可选参数
alter table [表名] add 字段名 memo [null] 增加备注型字段,[null]可选参数
 
alter table [表名] add 字段名 varchar(N) [null] 增加变长文本型字段 大小 为N(1~255)
alter table [表名] add 字段名 char [null] 增加定长文本型字段 大小固定为255
 
alter table [表名] add 字段名 Datetime default 函数 增加日期型字段,其中 函数 可以是 now(),date()等,表示缺省值
(上面都是最常用的,还有其他的属性,可以参考下面的数据类型描述)
 
删除字段: alter table [表名] drop 字段名
 
修改变长文本型字段的大小:alter table [表名] alter column 字段名 varchar(N)
 
删除表: drop table [表名]
 
 
 

SQL查询表,表的所有字段名

SQL SERVER

查看所有表名:
select name from sysobjects where type='U'

查询表的所有字段名:
Select name from syscolumns Where ID=OBJECT_ID('表名')

select * from information_schema.tables
select * from information_schema.views
select * from information_schema.columns


ACCESS

查看所有表名:
select name from MSysObjects where type=1 and flags=0

MSysObjects是系统对象,默认情况是隐藏的。通过工具、选项、视图、显示、系统对象可以使之显示出来。

Oracle
select cname from col where tname='ZW_YINGYEZ'

select column_name from user_tab_columns where table_name='ZW_YINGYEZ'

查询表字段数
select count(column_name) from user_tab_columns where table_name='表名';


标签:SQL添加表字段以及SQL查询表 表的所有字段名 

欢迎加入VIP,【VIP售价:只要288元永久VIP会员】畅享商业棋牌游戏程序下载,点击开通!

下载说明


☉本站所有源码和资源均由站长亲自测试-绝对保证都可以架设,运营!
☉如源码和资源有损坏或所有链接均不能下载,请告知管理员,

☉本站软件和源码大部分为站长独资,资源购买和收集,放心下载!

☉唯一站长QQ:1004003180  [人格担保-本站注重诚信!]

☉购买建议E-mail:1004003180@qq.com   源码收购 E-mail:1004003180@qq.com    

☉本站文件解压密码  【文章内都自带解压密码,每个密码不同!】


本站提供的所有源码,均来源站长提供,仅学习交流 浙ICP备09009969号

由此产生不良后果和法律责任与本站无关,如果侵犯了您的版权,请来信告知 1004003180@qq.com 将及时更正和删除! 

Copyright © 2008-2024 棋牌资源网,你身边的棋牌资源下载站    All Rights Reserved