You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

新手求助:如何将《SQL Queries for Mere Mortals》脚本导入Oracle数据库

Loading "SQL Queries for Mere Mortals" Scripts into Oracle

Hey there! As someone who’s worked with Oracle and used that book to build up SQL fundamentals, let me walk you through the steps to get those scripts loaded into your database—nice and straightforward, perfect for a beginner.

Step 1: Locate the Oracle-specific scripts

First, track down the script files that come with the book. Most copies include a companion disc, or you might have downloaded them (look for files labeled specifically for Oracle—this book supports multiple databases, so don’t grab the MySQL/SQL Server versions by mistake!). You’ll end up with one or more .sql files containing table creations, sample data, and other objects from the book.

To avoid messing with your existing database objects, create a separate user just for practicing with this book. This keeps your main database clean and prevents naming conflicts. Open your Oracle tool (like SQL*Plus or SQL Developer) and run these commands as a user with DBA privileges:

-- Create a new practice user
CREATE USER mortals_practice IDENTIFIED BY your_secure_password;

-- Grant necessary permissions to create tables, views, etc.
GRANT CONNECT, RESOURCE, CREATE VIEW TO mortals_practice;

Replace your_secure_password with a password you’ll remember.

Step 3: Run the scripts using your preferred Oracle tool

You’ve got two easy options here, depending on whether you prefer command-line or graphical tools:

Option A: SQL*Plus (command-line)

  1. Open SQL*Plus and log in to your new practice user:
    sqlplus mortals_practice/your_secure_password@your_oracle_connection_string
    
    (Replace your_oracle_connection_string with your database’s connection details—this might be something like localhost:1521/ORCL for a local install.)
  2. Run the script using the @ command. If your script file is in a folder with spaces, wrap the path in quotes:
    @"C:\Path\To\Your\OracleScripts\CreateSampleTables.sql"
    

Option B: Oracle SQL Developer (graphical, beginner-friendly)

  1. Launch SQL Developer and create a connection to your mortals_practice user.
  2. Go to File > Open and select the .sql script file from the book.
  3. Click the green "Run Script" button (looks like a play arrow) at the top of the editor. If the book has multiple scripts, follow the order specified in the book’s introduction—they’re designed to build on each other.

Step 4: Verify the script ran successfully

After running the script, check the output for any error messages. If you see "Table created." or "View created." messages, you’re good to go! If you get errors like "ORA-00955: name is already used by an existing object", that means you probably ran the script twice—just drop the existing objects (or create a fresh practice user) and try again.

Quick Pro Tip

Take it slow! The book’s examples are meant to be worked through chapter by chapter. Instead of running all scripts at once, run the ones relevant to the chapter you’re reading. This helps you connect the script content to the concepts you’re learning.

内容的提问来源于stack exchange,提问作者katjar3544

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:50:02