gpt4 book ai didi

sql-server - 插入SQL服务器

转载 作者:行者123 更新时间:2023-12-03 03:09:47 24 4
gpt4 key购买 nike

我必须创建一个数据库,创建表并插入信息:

我有数据库和表,但是当我插入时遇到问题......

如有任何帮助,我们将不胜感激。这是我第一次尝试 SQL。

/* This script creates the SQL database and tables
** for Kudler Fine Foods
** Human Resources
*/



CREATE DATABASE Mor ;
Go

USE Mor
CREATE TABLE Employee (
Emp_id int NOT NULL IDENTITY(1,1),
Last_name varchar(25),
First_name varchar(25),
Address varchar(40),
City varchar (15),
State char(2),
Telephone_area_code varchar(3),
Telephone_number varchar(8),
Job_title varchar(50),
Hire_date smalldatetime,
Wage money,
Gender char(1),
Race varchar(25),
Age int );

CREATE TABLE Job_title (
Job_title varchar (50) PRIMARY KEY,
EEO_1_Classification varchar(30),
Job_description varchar(250),
Exempt_Non_Exempt_Status bit );




/* This script inserts values into Job_title table
** (Note: 1 means exempt (salaried)
** 0 means non-exempt (hourly)
*/




INSERT INTO Job_title

VALUES
('Accounting Clerk', 'Office/Clerical',
'Computes, classifies, records, and verifies numerical data for use in maintaining
accounting records.',
'0');

VALUES
('Assistant Manager', 'Officials & Managers',
'Supervises and coordinates activities of workers in department of food store.
Assists store manager in daily operations of store.' ,
'1');
VALUES
('Bagger','Sales Workers',
'Places customer orders in bags. Performs carryout duties for customers.',
'0');

VALUES
('Cashier','Sales Workers',
'Operates cash register to itemize and total customer’s purchases in grocery
store.',
'0');

VALUES
('Computer Support Specialist','Technician',
'Installs, modifies, and makes minor repairs to personal computer hardware and
software systems, and provides technical assistance and training to system
users.',
'0');

VALUES
('Dir. of Fin. & Acct.','Officials & Managers',
'Plans and directs the finance and accounting activities for Kudler Fine Foods.',
'1');


VALUES
('Asst. - Bakery & Pastry','Craft Workers (Skilled)',
'Obtains or prepares food items requested by customers in retail food store.',
'0');


VALUES
('Asst. - Butchers & Seafood Specialists','Operatives (Semi skilled)',
'Obtains or prepares food items requested by customers in retail food store.',
'0');


VALUES
('Stocker','Office/Clerical',
'Stores, prices and restocks merchandise displays in store.',
'0')

最佳答案

首先,您需要为插入语句中的每个“值”子句添加一条插入语句。

INSERT INTO Job_title
(Job_title, EEO_1_Classification, Job_description, Exempt_Non_Exempt_Status )
VALUES ('Accounting Clerk', 'Office/Clerical', 'Computes, classifies, records, and verifies numerical data for use in maintaining accounting records.', '0');

INSERT INTO Job_title
(Job_title, EEO_1_Classification, Job_description, Exempt_Non_Exempt_Status )
VALUES ('Assistant Manager', 'Officials & Managers', 'Supervises and coordinates activities of workers in department of food store. Assists store manager in daily operations of store.' , '1');

Job_Title 表中的 EEO_1_Classification 列是 varchar(30),它太短,请将其设为 varchar(200) 或更大一点的值。

您的位列(Job_Title 上的第四个)接受 0 和 1 值 - 不要在值两边加上引号。

关于sql-server - 插入SQL服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3137078/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com