Форматы вывода sqlite3

Работая напрямую в файле базы sqlite3, зачастую, бывает полезно вывести результат запроса в определенном формате. Sqlite3 поддерживает достаточно большое количество форматов вывода. Здесь я приведу наиболее интересные.

Итак, начнем c .mode list:

sqlite> .mode list
sqlite> select * from tbl1;
hello|10
goodbye|20
sqlite>

Как дополнение, вы можете использовать команду “.separator”, которая определит разделитель:

sqlite> .separator ", "
sqlite> select * from tbl1;
hello, 10
goodbye, 20
sqlite>

Следующим режимом вывода будет .mode line:

sqlite> .mode line
sqlite> select * from tbl1;
one = hello
two = 10

one = goodbye
two = 20
sqlite>

Пример вывода для .mode column:

sqlite> .mode column
sqlite> select * from tbl1;
one         two       
----------  ----------
hello       10        
goodbye     20        
sqlite>

А теперь мы отключим вывод заголовков колонок с помощью .header off:

sqlite> .header off
sqlite> select * from tbl1;
hello         10    
goodbye       20    
sqlite>

Ну и на сладкое оставлю последний пример вывода, используя .mode insert, с помощью которого можно вывести таблицу в виде sql-запросов:

sqlite> .mode insert new_table
sqlite> select * from tbl1;
INSERT INTO 'new_table' VALUES('hello',10);
INSERT INTO 'new_table' VALUES('goodbye',20);
sqlite>

61 комментарий к “Форматы вывода sqlite3

  1. Greetings! I know this is kind of off topic but I was wondering which blog platform are you using for this site?
    I’m getting fed up of WordPress because I’ve had problems with hackers and I’m looking at alternatives for another platform.
    I would be great if you could point me in the
    direction of a good platform.

  2. hello there and thank you for your info – I have definitely
    picked up something new from right here.

    I did however expertise some technical points using this web site,
    as I experienced to reload the site a lot of times previous to I could get it to load
    correctly. I had been wondering if your web hosting is
    OK? Not that I am complaining, but slow loading instances times will often affect your placement in google and
    could damage your quality score if ads and marketing with Adwords.
    Anyway I’m adding this RSS to my email and could look out for much more of your respective fascinating
    content. Make sure you update this again very soon.

  3. It is perfect time to make a few plans for the longer term and it’s
    time to be happy. I have learn this put up and if I may I
    want to suggest you some attention-grabbing things or tips.
    Maybe you could write next articles referring to this article.

    I wish to read even more issues approximately it!

  4. I have been surfing online more than three hours today, yet I never found any interesting article like yours.
    It is pretty worth enough for me. In my opinion, if all
    website owners and bloggers made good content as you did, the
    web will be much more useful than ever before.

  5. Hi there everyone, it’s my first pay a quick visit at this web page, and article
    is genuinely fruitful in support of me,
    keep up posting these types of articles or reviews.

  6. Pretty section of content. I just stumbled upon your blog and in accession capital to assert
    that I acquire in fact enjoyed account your blog posts.
    Any way I’ll be subscribing to your feeds and even I achievement you access
    consistently quickly.

  7. hello there and thank you for your info – I’ve definitely picked up anything new from right here.
    I did however expertise some technical points using this website, as
    I experienced to reload the website a lot of times previous to I could get it to load
    correctly. I had been wondering if your web host is OK?
    Not that I’m complaining, but sluggish loading instances times
    will sometimes affect your placement in google and
    could damage your quality score if advertising and marketing with Adwords.
    Anyway I’m adding this RSS to my e-mail and could look out for
    a lot more of your respective intriguing content. Ensure that
    you update this again soon.

  8. Its like you read my mind! You appear to know a lot
    about this, like you wrote the book in it or something.

    I think that you could do with some pics to drive
    the message home a little bit, but other than that,
    this is wonderful blog. A fantastic read. I will definitely be back.

  9. First off I would like to say terrific blog!
    I had a quick question which I’d like to ask if you don’t mind.

    I was curious to find out how you center yourself and clear your mind prior to writing.
    I’ve had difficulty clearing my mind in getting my thoughts out.
    I do enjoy writing but it just seems like the first 10 to 15 minutes tend
    to be wasted just trying to figure out how to begin. Any ideas or tips?
    Cheers!

  10. I think this is among the most important info for me. And i’m glad
    reading your article. But should remark on some general things,
    The web site style is great, the articles is really excellent : D.
    Good job, cheers

  11. Hello outstanding website! Does running a blog
    like this require a lot of work? I’ve very little knowledge of
    programming however I was hoping to start my own blog in the near future.
    Anyway, should you have any recommendations or techniques for new blog owners please share.
    I know this is off topic however I just had to ask. Cheers!

  12. Hi there, just became aware of your blog through Google, and found that it’s truly informative.
    I’m going to watch out for brussels. I will be grateful if you continue this in future.
    Lots of people will be benefited from your writing.
    Cheers!

  13. My programmer is trying to persuade me to
    move to .net from PHP. I have always disliked the idea because of the costs.
    But he’s tryiong none the less. I’ve been using WordPress on various websites for about a year
    and am nervous about switching to another platform. I have heard very
    good things about blogengine.net. Is there a way I can import all my wordpress posts into
    it? Any kind of help would be greatly appreciated!

  14. Somebody essentially lend a hand to make significantly articles I’d state.
    This is the first time I frequented your website page and up to now?
    I amazed with the analysis you made to make this actual submit extraordinary.
    Fantastic activity!

  15. Hey there! I understand this is kind of off-topic however I needed
    to ask. Does operating a well-established blog like yours take
    a large amount of work? I am brand new to running a
    blog but I do write in my journal everyday. I’d like to start a blog so
    I can easily share my own experience and thoughts online.
    Please let me know if you have any kind of suggestions or tips for
    new aspiring bloggers. Appreciate it!

  16. you’re in point of fact a excellent webmaster.
    The web site loading velocity is amazing. It seems that you’re doing any distinctive trick.

    Moreover, The contents are masterwork. you have
    performed a excellent activity on this subject!

  17. I was recommended this blog by my cousin. I am not sure whether
    this post is written by him as no one else know such detailed
    about my problem. You are incredible! Thanks!

  18. Hmm it seems like your blog ate my first comment (it was
    super long) so I guess I’ll just sum it up what I wrote and say, I’m thoroughly enjoying your blog.
    I too am an aspiring blog blogger but I’m still
    new to everything. Do you have any tips for novice blog writers?
    I’d genuinely appreciate it.

  19. You are so cool! I don’t think I’ve read through anything like that before.
    So nice to discover somebody with some unique thoughts on this topic.
    Really.. thanks for starting this up. This web site is one thing that’s needed on the
    internet, someone with a bit of originality!

  20. Hello there! This post couldn’t be written any better!
    Reading through this article reminds me of my previous roommate!
    He always kept preaching about this. I most certainly will send this information to him.

    Pretty sure he’s going to have a very good read. Thank you for sharing!

  21. An outstanding share! I’ve just forwarded this onto a co-worker who has been conducting a little homework on this.
    And he actually ordered me lunch because I found it for him…
    lol. So allow me to reword this…. Thanks for the
    meal!! But yeah, thanx for spending time to talk about this subject here on your website.

  22. Oh my goodness! Awesome article dude! Thanks, However I am having difficulties with
    your RSS. I don’t understand why I am unable to join it.
    Is there anybody else getting similar RSS issues? Anybody who knows the solution can you kindly respond?
    Thanks!!

  23. I have been surfing online more than three hours today, yet I never found any interesting article like yours.
    It is pretty worth enough for me. Personally, if all site owners and
    bloggers made good content as you did, the net will be much more useful than ever before.

  24. Hello would you mind letting me know which web host you’re utilizing?

    I’ve loaded your blog in 3 different web browsers and I must
    say this blog loads a lot faster then most.
    Can you recommend a good internet hosting provider at a fair price?
    Thanks, I appreciate it!

  25. Hey there would you mind letting me know which hosting company you’re
    utilizing? I’ve loaded your blog in 3 different web browsers and
    I must say this blog loads a lot faster then most. Can you recommend a good internet hosting provider at a reasonable
    price? Thanks, I appreciate it!

  26. Hey There. I found your blog using msn. This is an extremely well written article.

    I will be sure to bookmark it and come back to read more of your useful
    info. Thanks for the post. I’ll certainly comeback.

  27. I don’t even know how I ended up here, but I thought this post
    was great. I do not know who you are but certainly you are going to a
    famous blogger if you are not already 😉 Cheers!

  28. My partner and I stumbled over here from a different web address and thought
    I might check things out. I like what I see so now i’m following you.
    Look forward to exploring your web page for a second time.

  29. Hmm is anyone else encountering problems with the pictures
    on this blog loading? I’m trying to find out if its a problem on my end or if it’s the blog.
    Any suggestions would be greatly appreciated.

  30. Excellent post. I was checking constantly this blog and I am impressed!
    Very useful info particularly the last part 🙂 I care for such info a
    lot. I was seeking this certain info for a long time.

    Thank you and best of luck.

  31. Hey outstanding blog! Does running a blog similar
    to this require a lot of work? I have virtually no knowledge
    of programming but I had been hoping to start my own blog in the near future.
    Anyways, if you have any recommendations or techniques
    for new blog owners please share. I know this is off topic nevertheless I simply had to
    ask. Kudos!

  32. Уведомление: Homepage

Оставить ответ

Ваш адрес email не будет опубликован. Обязательные поля помечены *