永发信息网

数据库导入导出单个表的SQL语句怎么写

答案:3  悬赏:40  手机版
解决时间 2021-05-06 08:12
  • 提问者网友:难遇难求
  • 2021-05-05 14:16
数据库导入导出单个表的SQL语句怎么写
最佳答案
  • 五星知识达人网友:山河有幸埋战骨
  • 2021-05-05 15:42
insert into tableName1(fieldName1,fieldNmae2) select fieldName1,fieldNmae2 from tableName2
全部回答
  • 1楼网友:污到你湿
  • 2021-05-05 18:17
不太明白你说的导入导出的意思,是否是将现有数据库1中的一个表搬家到数据库2中?如果是的话可以使用下面语句: 我下面示例的数据库名为 myDataBase,表名Users。 USE [myDataBase] GO IF EXISTS (SELECt * FROM dbo.sysobjects WHERe id = OBJECT_ID(N'[DF_Users_UserResetPasswordTime]') AND type = 'D') BEGIN ALTER TABLE [dbo].[Users] DROp CONSTRAINT [DF_Users_UserResetPasswordTime] END GO IF EXISTS (SELECT * FROM dbo.sysobjects WHERe id = OBJECT_ID(N'[DF_Users_UserIsLocks_1]') AND type = 'D') BEGIN ALTER TABLE [dbo].[Users] DROp CONSTRAINT [DF_Users_UserIsLocks_1] END GO USE [klm_v1.0] GO IF EXISTS (SELECT * FROM sys.objects WHERe object_id = OBJECT_ID(N'[dbo].[Users]') AND type in (N'U')) DROP TABLE [dbo].[Users] GO USE [klm_v1.0] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[Users]( [UserID] [int] IDENTITY(1,1) NOT NULL, [UserLoginName] [varchar](50) NOT NULL, [UserPassword] [varchar](50) NULL, [UserEmail] [varchar](50) NOT NULL, [UserQuestion] [varchar](150) NULL, [UserAnswer] [varchar](150) NULL, [UserLastIP] [varchar](50) NULL, [UserLastDatetime] [datetime] NULL, [UserLoginNum] [int] NULL, [UserCheckCode] [varchar](150) NULL, [UserResetPasswordTime] [datetime] NULL, [UserAuditingTF] [bit] NULL, [UserIsLocks] [bit] NULL, [UserIsPerson] [bit] NULL, [UserIsCompany] [bit] NULL, [UserAddDate] [datetime] NULL, CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED ( [UserID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户账号主键' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserID' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'账号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserLoginName' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'密码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserPassword' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'电子信箱' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserEmail' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'密码问题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserQuestion' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'密码答案' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserAnswer' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后登陆IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserLastIP' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后登陆时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserLastDatetime' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'登陆次数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserLoginNum' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮箱验证代码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserCheckCode' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'重置密码时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserResetPasswordTime' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'会员审核' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserAuditingTF' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否锁定' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserIsLocks' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'个人会员' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserIsPerson' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'企业会员' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserIsCompany' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'创建日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserAddDate' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户帐号密码表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users' GO ALTER TABLE [dbo].[Users] ADD CONSTRAINT [DF_Users_UserResetPasswordTime] DEFAULT (getdate()) FOR [UserResetPasswordTime] GO ALTER TABLE [dbo].[Users] ADD CONSTRAINT [DF_Users_UserIsLocks_1] DEFAULT ((0)) FOR [UserIsLocks] GO
  • 2楼网友:骨子里都是戏
  • 2021-05-05 17:14

什么样的数据库啊 mysql的有工具可以自己导出。 sqlserver的也可以用工具导入导出的。

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯