Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2013
    Posts
    2

    Unhappy Unanswered: PSQL Command Line help

    I am trying to learn PostgreSQL on my own for a side project this summer. I keep running into a problem when I insert items into a tutorial database I am using while I read through a book I found. On the command line for PSQL it shows the database name then a => or =# which i understand and if I continue onto multiple lines it changes to -> or -#. The problem I am having is that on insert statements it sometimes changes to '> and then is unresponsive and I have to close the PSQL shell down and reopen it to continue playing around. I have tried to research what it means and how to break out of the unresponsive state but I honestly don't know what to even look up. I have skimmed through the manual for 9.2 and read through this book but I can't figure it out. Can anyone please explain to me what '> means so I can figure out what I am doing wrong and possibly be able to fix my errors?

  2. #2
    Join Date
    Oct 2010
    Location
    Orlando, FL
    Posts
    311
    Provided Answers: 1
    Here is how it works and follow along after each return:

    Code:
    test=> \d stuff
                Table "public.stuff"
     Column |          Type          | Modifiers
    --------+------------------------+-----------
     id     | integer                | not null
     name   | character varying(200) | not null
     date   | date                   |
    Indexes:
        "stuff_pkey" PRIMARY KEY, btree (id)
        "stuff_name_key" UNIQUE CONSTRAINT, btree (name)
    
    test=> INSERT INTO stuff
    test-> (
    test(> id, name, date
    test(> )
    test-> VALUES
    test-> (
    test(> '1',
    test(> 'Twizzers',
    test(> '2013-06-17'
    test(> )
    test-> ;
    INSERT 0 1
    You can see the 'psql' client changes based on what gets called for each line.

  3. #3
    Join Date
    Jun 2013
    Posts
    2
    I want to thank you for taking the time to help me with this. I am able to follow what you showed me. The problem I am having is that I occasionally get a line that shows:

    test '>

    when this happens I cannot break out of it and I cannot enter any commands or even close psql. I was hoping someone would know what causes this and how to break out of it so that I don't have to close my psql shell and reopen it to continue working.

  4. #4
    Join Date
    Oct 2010
    Location
    Orlando, FL
    Posts
    311
    Provided Answers: 1
    I've not seen that sadly nor could I replicate it with trying some quick (sloppy) SQL commands. How often do you get this? Every single time in psql?

    What about if you switch to a GUI like pgAdmin3 (with server tools installed) and use the psql window there? Does it do it also?

  5. #5
    Join Date
    Dec 2012
    Posts
    43
    Quote Originally Posted by Ewheels View Post
    I want to thank you for taking the time to help me with this. I am able to follow what you showed me. The problem I am having is that I occasionally get a line that shows:

    test '>

    when this happens I cannot break out of it and I cannot enter any commands or even close psql. I was hoping someone would know what causes this and how to break out of it so that I don't have to close my psql shell and reopen it to continue working.
    psql gives you a hint: an ending ' is required.
    A short example:
    Code:
    thomas=> select 'foo
    thomas'> this is still a literal string
    thomas'> and ends now:';
                ?column?            
    --------------------------------
     foo                           +
     this is still a literal string+
     and ends now:
    (1 Zeile)
    
    thomas=>
    The sign before ">" shows what psql wants unless it's an equal sign "=".

    An other example. It shows an incomplete SQL-statement:
    Code:
    thomas=> select
    thomas-> now();
                  now              
    -------------------------------
     2013-06-19 20:44:46.081761+02
    (1 Zeile)
    
    thomas=>

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •