Sponsored Content
Full Discussion: creating a schema
Top Forums UNIX for Dummies Questions & Answers creating a schema Post 302263526 by zodester on Monday 1st of December 2008 08:52:43 PM
Old 12-01-2008
creating a schema

hi guys,
Unix dummy here.
I need help creating a script for class.
The assignment reads as follows:
create a script that will create a new schema in schema.txt, it must accept 7 arguments (the first being the name of the schema) the other 6 being the 6 field names. the schema has to be tested to make sure it isn't in the file schema.txt and if all passes then the arguments should be appended to the file schema.txt

this is what I have so far:

#!/bin/sh
if [ ! $# -ge 2 ] && [ ! $# -le 7 ]
then
echo "Usage: ns.sh <schema_name> <field_names>"
elif [ ! -f schemas.txt ]
echo "schemas.txt": file could not be found.
elif [ ! -r schemas.txt ]
echo "schemas.txt": unable to read file.
elif [ ! -w schemas.txt ]
echo "schemas.txt": unable to write upon file.
elif [ "`grep"^$1\" schema.txt`" ]
echo schema already defined as $1
else
$@ >> schema.txt
fi


when I run it, this happens:

sena@linprog1.cs.fsu.edu:~/a5>ns.sh cars make model year
ns.sh: line 7: syntax error near unexpected token `elif'
ns.sh: line 7: `elif [ ! -r schemas.txt ]'


As far as appending the arguments to schema I don't know what to do
Any help would be awesome!
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script for checking schema satistics in Oracle

I have a script which gives the output of schemas in Oracle DB : #!/bin/ksh ps -ef | grep -v grep | grep ora_pmon_$1 | wc -l | while read CONTROL do if ; then ORACLE_HOME=/u01/app/oracle/product/9.2.0 export ORACLE_HOME PATH=$ORACLE_HOME/bin:$PATH:/bin:/usr/bin:usr/local/bin:. ... (0 Replies)
Discussion started by: run_time_error
0 Replies

2. Shell Programming and Scripting

find a column in a schema

Hi, I need my script to accept a column name and give all the tables and its schema. Any kind of help is appreciated... Thanks in advance... (2 Replies)
Discussion started by: bankimmehta
2 Replies

3. UNIX and Linux Applications

Toad for Oracle 11G - schema browser not working

Need a help Schema browser in Toad not listing the tables when i connected to Oracle 11g schema did any body faced the issue... ? How to resolve the issue (0 Replies)
Discussion started by: girija
0 Replies

4. Emergency UNIX and Linux Support

Toad for Oracle 11G Schema browser

Need a help ..Schema browser in Toad not listing the tables when i connected to Oracle 11g schema did any body faced the issue... ? How to resolve the issue.. I need it asap thats y posted here Thanks (5 Replies)
Discussion started by: girija
5 Replies

5. Cybersecurity

LDAP rfc2307bis.schema or nis.schema?

Hi guys, we are implementing new ldap in our organization exclusively for Linux authentication purposes. As we are new to the subject, I would appreciate help regarding which schema to use to create group of users and accounts / passwords entries? I see both schemas listed in subject above... (0 Replies)
Discussion started by: Lastminute
0 Replies

6. Shell Programming and Scripting

Parallel export of all oracle DB schema.

In my Oracle db there are 4 schemas. All the username & passwords are stored in a text file. I am using a while loop to export all the schemas. It read the first line and doing the export. For all users it export one by one. But I need all the schemas will exported simultaneously. i.e. all the... (1 Reply)
Discussion started by: priya001
1 Replies

7. UNIX for Dummies Questions & Answers

How can I import a particular schema from full dump in Oracle?

Hi All, I have a full oracle dump file that I have exported from a production server. I want to import a specific schema out of the full dump. Is that possible in oracle. What will be the command for that? (6 Replies)
Discussion started by: Palak Sharma
6 Replies
DROP 
SCHEMA(7) SQL Commands DROP SCHEMA(7) NAME
DROP SCHEMA - remove a schema SYNOPSIS
DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ] DESCRIPTION
DROP SCHEMA removes schemas from the database. A schema can only be dropped by its owner or a superuser. Note that the owner can drop the schema (and thereby all contained objects) even if he does not own some of the objects within the schema. PARAMETERS
IF EXISTS Do not throw an error if the schema does not exist. A notice is issued in this case. name The name of a schema. CASCADE Automatically drop objects (tables, functions, etc.) that are contained in the schema. RESTRICT Refuse to drop the schema if it contains any objects. This is the default. EXAMPLES
To remove schema mystuff from the database, along with everything it contains: DROP SCHEMA mystuff CASCADE; COMPATIBILITY
DROP SCHEMA is fully conforming with the SQL standard, except that the standard only allows one schema to be dropped per command, and apart from the IF EXISTS option, which is a PostgreSQL extension. SEE ALSO
ALTER SCHEMA [alter_schema(7)], CREATE SCHEMA [create_schema(7)] SQL - Language Statements 2010-05-14 DROP SCHEMA(7)
All times are GMT -4. The time now is 09:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy