美文网首页
Neo4j - CQL Admin

Neo4j - CQL Admin

作者: 韩维思 | 来源:发表于2018-11-23 10:14 被阅读0次

    1. Index

    1.1 Creating an Index

    CREATE INDEX ON:label (node)
    eg.
    CREATE (Dhawan:player{name: "shikar Dhawan", YOB: 1995, POB: "Delhi"})
    Following is a sample Cypher Query to create an index on the node Dhawan in Neo4j.
    CREATE INDEX ON:player(Dhawan)

    Creating an Index

    1.2 Deleting an Index

    Neo4j CQL provides a "DROP INDEX" command to drop an existing index of a Node or Relationshis property.
    DROP INDEX ON:label(node)
    Following is a sample Cypher Query to create an index on the node named “Dhawan” in Neo4j.
    DROP INDEX ON:player(Dhawan)

    Delete an Index

    2. Create Unique Constraint

    MATCH (root {name: "Dhawan"}) 
    CREATE UNIQUE (root)-[:LOVES]-(someone) 
    RETURN someone 
    

    eg.

    CREATE(Dhawan:player{id:001, name: "shikar Dhawan", YOB: 1995, POB: "Delhi"}) 
    CREATE(Jonathan:player {id:002, name: "Jonathan Trott", YOB: 1981, POB: "CapeTown"}) 
    CREATE(Sangakkara:player {id:003, name: "Kumar Sangakkara", YOB: 1977, POB: "Matale"}) 
    CREATE(Rohit:player {id:004, name: "Rohit Sharma", YOB: 1987, POB: "Nagpur"}) 
    CREATE(Virat:player {id:005, name: "Virat Kohli", YOB: 1988, POB: "Delhi"}) 
    

    Then
    CREATE CONSTRAINT ON (n:player) ASSERT n.id IS UNIQUE
    Then, input:
    CREATE (Jadeja:player {id:002, name: "Ravindra Jadeja", YOB: 1988, POB: "NavagamGhed"})
    Error:

    Constraint Error

    3. Drop Unique

    DROP CONSTRAINT ON (node:label) 
    ASSERT node.id IS UNIQUE 
    

    eg.
    Following is a sample Cypher Query to remove the UNIQUE constraint on the property id.

    DROP CONSTRAINT ON (n:player) 
    ASSERT n.id IS UNIQUE 
    

    Result:


    Drop Constraint Result

    相关文章

      网友评论

          本文标题:Neo4j - CQL Admin

          本文链接:https://www.haomeiwen.com/subject/yvdrqqtx.html