SQL语句记录

来源:互联网 发布:linux更新系统 编辑:程序博客网 时间:2024/06/05 17:49

创建表:

CREATE TABLE [dbo].[FoundViewTable]
(
    [基金代码] INT NOT NULL, 
    [基金名称] NCHAR(10) NULL, 
    [20150607] FLOAT NULL, 
    CONSTRAINT [PK_FoundViewTable] PRIMARY KEY ([基金代码]) 
)

创建数据库:

CREATE TABLE [dbo].[信息记录] (
    [学号] NCHAR (10) NOT NULL,
    [姓名] NCHAR (10) NULL,
    CONSTRAINT [PK_信息记录] PRIMARY KEY CLUSTERED ([学号] ASC)
);



查询:
Select * from tb_stu where name = '' and sex = ''


sql语句
alter table tableName add columnName dataType

tableName :这个替换为你需要修改的表名
columnName :你需要添加的字段名
dataType:该字段对应的数据类型


添加列:
ALTER table tb_stu ADD address VARCHAR(20) NULL


删除列:
alter table tb_stu drop column columnName   


添加行:
insert into tb_stu(num, name, sex, age, class) Values('1042163', '', '', '', '',)


修改行:
update tb_stu set name = '', sex = '', age = '', class = '' where num = '1042163'


删除行:
delete from tb_stu where num = '1042163'


修改行:
UPDATE Person SET Address = 'Zhongshan 23', City = 'Nanjing'
WHERE LastName = 'Wilson'


INSERT INTO [dbo].[FoundViewTable] ([基金代码], [基金名称], [2015/06/07]) VALUES (N'1042163   ', N'clom2     ', 3.24)
INSERT INTO [dbo].[FoundViewTable] ([基金代码], [基金名称], [2015/06/07]) VALUES (N'166002    ', N'中欧蓝筹基金    ', 1.559)
INSERT INTO [dbo].[FoundViewTable] ([基金代码], [基金名称], [2015/06/07]) VALUES (N'454565    ', N'asdf      ', 445)
INSERT INTO [dbo].[FoundViewTable] ([基金代码], [基金名称], [2015/06/07]) VALUES (N'630001    ', N'华商主题基金    ', 2.929)
INSERT INTO [dbo].[FoundViewTable] ([基金代码], [基金名称], [2015/06/07]) VALUES (N'630002    ', N'基金信息2     ', 123)

0 0
原创粉丝点击